Support

Account

Home Forums General Issues Values for select field lost

Solving

Values for select field lost

  • Hello I have set up a select field with 3 values and one of them as default. This field is the base for the conditional logic of the following 2 text fields that are displayed on the front end.
    I have noticed that the default value is lost for all the posts that have been published with default value. (I have used the function “the_field” to call the value and see what it returns).
    Even for new posts when I publish them, the default value does not pass to the postmeta. After an update of the post nothing changes.
    However for older posts when I update them I see the default value displaying based on the conditions I have configured.
    Both for older and fresh published posts the default value is displayed on the field group block of the back end (edit post dashboard).
    Unfortunately, I have no clue after which plugin update this field stopped working properly.
    Could you please hint me how to resolve this or to which direction should I look ?

  • I’m back again to share more info on this issue.
    I found out that disabling the conditional logic for the 2nd and 3rd field of the group, makes the plugin to successfully pass the default values both for the 1st select field (not displayed on the front end) and the 2nd text field (displayed on the front end).
    However older posts keep missing the default value as configured for the 1st select field and only if I update 1 by 1 they show the right value.
    I Hope that the latest findings can help you to better figure what’s wrong.

  • Hi @stavros

    Thanks for all the info, but I don’t quite understand the issue.

    Can you perhaps put together a quick screencast of the issue and post a link to the video? This way, you can clearly show the issue as this is one of those tricky bugs that are hard to word.

    Thanks
    E

  • This reply has been marked as private.
  • Hi @stavros

    I would like to clarify some things about the default value of a field, because I believe you do not have any bugs, but just some logic issues with your code.

    A default value is only loaded when creating a new post. If that value is not saved (hidden by conditional logic), the the_field function will not return anything into your theme.

    If you were to save the value (turning off conditional logic), the default value would correctly POST to the save function and the value would be saved to the DB. The the_field function will not display the value.

    If you were to now add in the conditional logic to hide this field in the back end, the value will never be ‘deleted’ from the post and will still remain in the DB. This mean the the_field function will display the value which is hidden in the wp-admin.

    I think you need to take this into consideration with your code and add in some conditional statements that check if the ‘select’ field is ‘a’ or ‘b’.

    I hope that helps.

    Thanks
    E

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

The topic ‘Values for select field lost’ is closed to new replies.