@@ -258,6 +258,20 @@ abstract class Block extends Composer implements BlockContract
258258 */
259259 public $ usePostMeta = false ;
260260
261+ /**
262+ * The ACF block API version.
263+ *
264+ * @var int
265+ */
266+ public $ blockVersion = 2 ;
267+
268+ /**
269+ * Validate block fields as per the field group configuration.
270+ *
271+ * @var bool
272+ */
273+ public $ validate = true ;
274+
261275 /**
262276 * The block attributes.
263277 */
@@ -536,9 +550,9 @@ public function settings(): Collection
536550 'supports ' => $ this ->supports ,
537551 'enqueue_assets ' => fn ($ block ) => method_exists ($ this , 'assets ' ) ? $ this ->assets ($ block ) : null ,
538552 'textdomain ' => $ this ->getTextDomain (),
539- 'acf_block_version ' => 2 ,
553+ 'acf_block_version ' => $ this -> blockVersion ,
540554 'api_version ' => 2 ,
541- 'validate ' => true ,
555+ 'validate ' => $ this -> validate ,
542556 'use_post_meta ' => $ this ->usePostMeta ,
543557 'render_callback ' => function (
544558 $ block ,
@@ -596,11 +610,14 @@ public function toJson(): string
596610 'post_types ' ,
597611 'render_callback ' ,
598612 'use_post_meta ' ,
613+ 'validate ' ,
599614 ])->put ('acf ' , [
615+ 'blockVersion ' => $ this ->blockVersion ,
600616 'mode ' => $ this ->mode ,
601617 'postTypes ' => $ this ->post_types ,
602618 'renderTemplate ' => $ this ::class,
603619 'usePostMeta ' => $ this ->usePostMeta ,
620+ 'validate ' => $ this ->validate ,
604621 ])->put ('name ' , $ this ->namespace );
605622
606623 return $ settings ->filter ()->toJson (JSON_PRETTY_PRINT );
0 commit comments