Support

Account

Home Forums Backend Issues (wp-admin) True / False Field Type Limit

Solved

True / False Field Type Limit

    • dashawk

    • September 10, 2013 at 11:59 am

    Hi, I am new to the forum but I am an avid fan of ACF.

    I just have a little request if this is possible.

    My request is about the true/false field type. Can you put an additional feature for this field type where in it has a limitation in a post. For example if I have a top 10 items then I will use this field and if there are already 10 items marked as the top 10, this field will not show anymore.

    Hope my request is clear.

    Thanks to the Dev Team!

    • Elliot

    • September 10, 2013 at 12:39 pm

    Hi @dashawk

    Would you mind attaching an image demonstrating your idea visually? I’m having a hard time comprehending the question.

    Thanks
    E

    • dashawk

    • September 10, 2013 at 12:59 pm

    Hi elliot,

    Thanks for the quick reply, I am uploading the image of what my idea is all about.

    Thanks

    • Elliot

    • September 10, 2013 at 1:05 pm

    Hi @dashawk

    Thanks for the screenshot. I understand the question now.

    This is far to custom to include into the core im afraid. That said, it would be possible for you to write some custom code to do this for you.

    I would add a function to the wp_head action which would append some jquery to the page. You could query the DB for the amount of posts with this checkbox value (see docs for querying), then depending on the value, you could generate some jQuery to either remove / hide or disable the checkbox field.

    All up, it should only take 30 minutes or so.

    Good luck

    Thanks
    E

    • dashawk

    • September 10, 2013 at 1:09 pm

    Hi @elliot,

    Thanks for the suggestion, but I don’t know where to put my queries. I checked on the core->field->true_false codes but I am not certain where to put the conditions.

    Could you help me out what files to edit or what folder should I go to? I haven’t tried creating a new field type for acf though.

    Thanks

    • Elliot

    • September 10, 2013 at 3:45 pm

    Hi @dashawk

    You don’t need to create a custom field type (did I imply that? I did not mean to).
    All you need to do is add some custom script to the admin_head action.

    If you are not confident in doing this, I would advise you to contract a freelance developer to add the functionality into your site.

    Good luck

    Thanks
    E

    • dashawk

    • September 10, 2013 at 7:28 pm

    Hi @elliot,

    As what you suggested earlier, I gathered up an idea tried to implement my queries in the true_false field and I got carried away that the true_false field is fully modified by me and will not be able to serve its purpose anymore. So I created a custom field type instead 😀 out of it.

    This is actually a good experience to me and a new learning for today. I succesfully created a “Top[N] Field Type” as what I called it 😀 and it works perfectly.

    Thank you for the advise @elliot, really appreciate it.

    Cheers!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.