@@ -214,6 +214,7 @@ class FormHelper extends CoreFormHelper
214214 '{{hidden}}<label{{attrs}}>{{input}}{{text}}{{tooltip}}</label> ' ,
215215 'submitContainer ' =>
216216 '<div{{containerAttrs}} class="{{containerClass}}submit">{{content}}</div> ' ,
217+ 'errorClass ' => 'is-invalid ' ,
217218 ];
218219
219220 /**
@@ -342,7 +343,6 @@ public function __construct(View $View, array $config = [])
342343 {
343344 $ this ->_defaultConfig = [
344345 'align ' => static ::ALIGN_DEFAULT ,
345- 'errorClass ' => 'is-invalid ' ,
346346 'grid ' => [
347347 static ::GRID_COLUMN_ONE => 2 ,
348348 static ::GRID_COLUMN_TWO => 10 ,
@@ -380,6 +380,11 @@ public function create(mixed $context = null, array $options = []): string
380380 'spacing ' => null ,
381381 ];
382382
383+ // This is only for backwards compatibility with CakePHP < 5.2
384+ if ($ this ->getConfig ('errorClass ' )) {
385+ $ this ->setConfig ('templates.errorClass ' , $ this ->getConfig ('errorClass ' ));
386+ }
387+
383388 return parent ::create ($ context , $ this ->_processFormOptions ($ options ));
384389 }
385390
@@ -498,7 +503,7 @@ public function control(string $fieldName, array $options = []): string
498503 isset ($ options ['append ' ]) ||
499504 isset ($ options ['prepend ' ])
500505 ) {
501- $ options ['injectErrorClass ' ] = $ this ->_config [ ' errorClass '] ;
506+ $ options ['injectErrorClass ' ] = $ this ->getConfig ( ' templates. errorClass ') ;
502507 }
503508
504509 unset(
0 commit comments