Viewing 1 replies (of 1 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    Unfortunately that is not possible with the built-in helpers that Advanced Forms provide. af_add_error actually adds an error to ACF but unfortunately ACF doesn’t make it particularly easy to add errors to nested fields.

    If you want to give this a shot yourself, you could try calling the undocumented function acf_add_validation_error provided by ACF. It’s defined in includes/validation.php at line 232. I don’t know the details but I believe it might work something like this to add an error to a subfield in a group:

    acf_add_validation_error( 'acf[GROUP_FIELD_KEY][SUB_FIELD_KEY]', 'ERROR MESSAGE' );

    That’s all the help I can offer I’m afraid as I’m not familiar enough with ACF internals. 🙂

Viewing 1 replies (of 1 total)

The topic ‘af_add_error for subfields’ is closed to new replies.