Support

Account

Home Forums General Issues Required sub_fields

Solving

Required sub_fields

  • Hi Elliot,
    is there a way to make subfields in a repeater field required? In other words if I make a parent field required, it still lets me to save a empty entry.

    Thanks
    Petr

  • The default setup doesn’t allow required sub-fields in Repeater fields I don’t think. This doesn’t mean to say you can’t come up with your own solution though.

    I’d approach this in either 2 routes:

    1) Create bit of jQuery that sits on the edit pages of WP and doesn’t allow the post to be Published until the required sub-fields are validated.

    2) Simply add conditional code to wherever you are using the sub-fields data to not output the element if the sub-field isn’t populated (I do this often for things like captions or titles in repeater fields)

    If you need help with the first bit of JS let me know as i’ve written something similar for a major project that required custom validation of ACF fields.

  • Thanks rmdev, it would be great if you could share that bit of JS. I am sure there are also other developers who will find it useful.

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

The topic ‘Required sub_fields’ is closed to new replies.