Title: af_add_error for subfields
Last modified: September 6, 2021

---

# af_add_error for subfields

 *  Resolved [gaet](https://wordpress.org/support/users/gaet/)
 * (@gaet)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/af_add_error-for-subfields/)
 * Hi,
 * I’ve the same problem that this issue : [https://wordpress.org/support/topic/af_add_error-doesnt-accept-fields-that-are-inside-clone-field/](https://wordpress.org/support/topic/af_add_error-doesnt-accept-fields-that-are-inside-clone-field/)
 * I’ld like to add extra validation to a sub field, but i think it’s not possible?
   
   any idea ?
 * Thanks

Viewing 1 replies (of 1 total)

 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/af_add_error-for-subfields/#post-14868101)
 * 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.

 * ![](https://ps.w.org/advanced-forms/assets/icon-256x256.png?rev=1894254)
 * [Advanced Forms for ACF](https://wordpress.org/plugins/advanced-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-forms/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * Last activity: [4 years, 8 months ago](https://wordpress.org/support/topic/af_add_error-for-subfields/#post-14868101)
 * Status: resolved