Support

Account

Home Forums Front-end Issues Field required = false Fails Validation

Helping

Field required = false Fails Validation

  • I’ve created a field group which is in use in several places including on the front end via acf_form. There are numerous required fields in the form but I need, under specific conditions, to make some of those fields non-required. Specifically I’m checking to see if the user is logged in and filtering the field output via acf/load_field and returning $field['required'] => false, exactly as suggested here: https://www.advancedcustomfields.com/resources/acf-load_field/.

    This _appears_ to work in so far as the fields _appear_ to be non-mandatory (no little red asterisk) but on submission those fields still fail validation, scrolling me back up the page to a “[field name] value is required” warning.

    Can anyone help me out? How can I exclude these fields from the validation process? Do I need to also filter the global acf JS object? Should it work as suggested on the referenced doc or does the fact that this is an acf_form mean that won’t work?

    Thanks for reading.

  • You’re problem may be how you are determining if the field is required. Please supply your filter code.

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

You must be logged in to reply to this topic.