Within a custom post page in WP admin I need to validate a group of ACF fields to make sure 1 has got data entered.
Whats the best way to approach this using ACF?
Use a custom script to validate and enqueue it with: acf/input/admin_enqueue_scripts
I doubt we can help you furthermore unless your clarify your needs; what kind validation, since ACF already has some sort of validation; do you need it live (with JS) or after the publishing step, etc.
Hi @tekhoi
ACF contains a setting on each field for ‘required’. By setting this to true, validation will be performed when saving the post.
If you require custom validation, please see this doc:
http://www.advancedcustomfields.com/resources/acf-validate_value/
Thanks
E
For future readers:
Please use the filter as documented here: http://www.advancedcustomfields.com/resources/filters/acfvalidate_value/
You can apply if to 1 of the 10 fields and within the function, look at the $_POST[‘acf’] array. You will need to find the field key’s for each of the fields and then loop over them to check if one of them contains a value.
If nothing is found, simply return false or a custom validation message.
Hope that helps