Overview
Field validation is enabled by default for all ACF Blocks. Existing posts with ACF Blocks are validated the next time the post is edited. If any fields fail validation, the post cannot be saved until those issues are resolved. In some cases, you may wish to disable field validation for a particular ACF Block. This doc shows how to disable field validation by adding the validate: false
attribute to the ACF key section of the block.json
file.
Validation for fields contained in ACF Blocks was introduced in ACF PRO 6.3. The fields in ACF Blocks can have any of the same validation rules applied to them as any custom field, such as being required, minimum and maximum values, and so on. This works the same way as validation for field groups assigned to posts, pages, or other data objects.
Usage
The validation attribute for ACF Blocks defaults to true
, so you will have to make adjustments to the block.json
file to prevent this behavior for an individual block. The validate: false
attribute is added to the ACF key section of your block.json
file:
{
"name": "acf/testimonial",
"title": "Testimonial",
"description": "A custom testimonial block that uses ACF fields.",
"style": [ "file:./testimonial.css" ],
"category": "formatting",
"icon": "admin-comments",
"keywords": ["testimonial", "quote"],
"acf": {
"mode": "preview",
"renderTemplate": "testimonial.php",
"validate": false
},
"supports": {
"anchor": true
}
}
Supercharge Your Website With Premium Features Using ACF PRO
Speed up your workflow and unlock features to better develop websites using ACF Blocks and Options Pages, with the Flexible Content, Repeater, Clone, Gallery Fields & More.