Forum Replies Created

  • Actually I managed to solve it, by adding extra check before getting and echoing the field with this structure:

    $make = get_post_meta($post_id, 'add-info-cat-auto_0_car-stamp');
    if (get_post_meta($post_id, 'add-info-cat-auto_0_car-stamp')) {
        echo $make[0] . ':';
    } if ($make[0] === 'Acura') {
        $model = get_post_meta($post_id, 'add-info-cat-auto_0_car-model-acura');
        echo $model[0];
    } elseif ($make[0] === 'Alfa Romeo') {
        $model = get_post_meta($post_id, 'add-info-cat-auto_0_car-model-alfa-romeo');
        echo $model[0];
    } elseif ($make[0] === 'Audi') {
        $model = get_post_meta($post_id, 'add-info-cat-auto_0_car-model-audi');
        echo $model[0];

    Since my car-make options are stored in one select, and models are in different selects it works better than clearing the values because you can’t really have 2 models. Thanks for you help again, have an awesome day! 🙂

  • Yep I tried the elseif approach and I can comfirm it only shows 1 value, but there is still something I need to clear up, when a post get edited it shows the old value in some cases, for example I had a bus with the following info:
    Make : Avia
    Model : Preslav
    The output was : Avia:Preslav

    Now I updated it to:
    Make : Daf
    Model : Leyland
    The output is : Daf:Preslav

    How can I clean up the old fields on post edit, using the save_post or pre_save_post filters? What should I be looking for.

    Also is there a way to remove the values from hidden fields with js if there is class ‘acf-clhi’ instant, like on Choice 2 – Text field 1 get val(“”) because there is class ‘acf-clhi’.

    Thanks for your answer again, it is the one that solved my question I will mark it as a solution, but I would be really thankfull if you could help me with this either. 🙂

  • Greetings John!
    The main problem is that what you say here
    “When a field is hidden by conditional logic that field is not submitted”

    Doesn’t work as expected on my end, it get posted even on the first publish of the post, for example I have Choice 1 that open select field 1 and Choice 2 that open select field 2 and close select field 1, but if I pick an option from select field 1 and choose Choice 2 and enter value in select field 2 too both of the values get posted, and it creates a problem because I have the following fieldset in order to make a dynamic filter.

    Car make : Acura, Aston etc..
    Car Model Acura : Integra, MDX etc..
    Car Model Aston : X70 etc..

    When you choose Acura you have to choose an option from the “Car Model Acura” select field, and if you then change the value to Aston you have to choose from the other car model select, the problem comes on the front-end, because :

    I use

    if (get_field('car-model-acura')) {
    echo the_field('car-model-acura'); 
    if (get_field('car-model-aston')) {
    echo the_field('car-model-aston');

    But on the front end it shows:
    Because I have values for both of the selects 🙁
    And each edit is adding a value if there is another car-make or model choosen, the worst part is that the website won’t hold posts published from moderators or administrators it’s front-end posting, and users won’t clear their values, if they decide to change the year of the car for example.

    One thing to mention is that I don’t have a reset value for the select fields, they start like :
    Alpha Romeo

    instead of

    Choose a model
    Alpha Romeo

    And maybe if I add these values and use javascript to add them if the field has the acf-clhi class, and then in the backend define that this value shouldn’t display it would be an adequate solution?

    Thanks for your time and descriptive answer! 🙂

  • Well since I need to conditionally hide a lot of fields, based on a radio button choice I guess I’ll end up with more than 300 fields, I will go for the repeater approach, because it looks more reliable to me, also there isn’t any fields which pop on load, and then hide.

    It seems like the page load time sagnifically reduced, so thanks for your help really. 🙂

  • James thank you in fact I noticed this about the repeated field, yesterday and this is the approach that I am about to take, I have one more question doe.

    Is the Repeater Field faster, and more reliable than the usual way that we use conditional logic for the fields.

    Thanks again for your answer.

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