Home Forums General Issues Display a text field based on a selected choice?


Display a text field based on a selected choice?

  • My page has a row of category buttons (built using the choices from a Select field) and I’d like to be able to display a short descriptive paragraph below the buttons based on which button has been pressed.

    The text paragraph would need to be associated with the choice somehow (so in my case with four choices I would need to have four text fields, but it could be any number of choices) but I don’t know how I could do this or how it could be entered in the admin area, there seems to be no facility for linking additional fields to select choices that I can see. If a choice was removed or added, then likewise the associated text field would also need to dynamically disappear or appear. Any ideas?

  • From your explanation this is what conditional logic is for. You create additional fields and set their conditional logic to show the field based on the selection made in your choice field.

  • That was my thought too but I can’t see any way for the logic to interact with the choices in the same field. As the categories are entered in the ACF admin interface it would ideally be something that is entered in the same field group as the choices, but there’s no obvious facility for adding additional fields to the Select field group.

    I suspect the only way to accomplish this the way I envisage it would be to customise ACF on a coding level, to add in the ability to add additional fields and have them linked to each choice in the select choices field, so they would be there along with the default fields such as Default Value, Instructions, Field Label and Field Name etc. Probably the most efficient method would be to have a second : on each line in the Choices box, so the first item is the value, then the label, then the line of text (which could possibly just be a pointer to some other field that the user creates).

    There’s possibly another way to get the same result, adding in those other text fields manually and then dragging out the field contents using some code in the WordPress functions or queries files. If I do this and get it working I’ll post my code here, just don’t hold your breath!

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

You must be logged in to reply to this topic.