Support

Account

Home Forums General Issues New field default value and conditional logic within render_field().

Unread

New field default value and conditional logic within render_field().

  • I’ve created a new field type (you can check it out at https://github.com/foyle82/acf-test-conditional ). While doing so I’ve used acf_render_field_wrap() to include a select and a textfield (inside of the method render_field()). I’ve also defined a conditional logic rule that states the select should not be visibile if the textfield value equals to “a”.

    Unfortunately this is how far as I can go: after several hours spent, I’m stuck on two fronts:

    1) I don’t know how to define a default value (both for the select and textfield). I’ve tried setting a [default_value] key/value inside of both acf_render_field_wrap() arrays, but that does not do the trick.

    2) The conditional logic seems to work, sort of. If the textfield is empty and if I type only the letter “a”, the select disappears as expected. But once I save, then no matter what I type, the conditional logic seems broken (nothing happens). If I delete the textfield contents and save, it works once more.

    Do you have any idea how to solve either of these issues?
    Thanks in advance!

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.