@@ -533,11 +533,7 @@ protected function getHtmlId($value, $attributes)
533533 return $ attributes ['id ' ];
534534 }
535535
536- if (strpos ($ value , '. ' )) {
537- return str_replace ('. ' , '_ ' , $ value );
538- }
539-
540- return $ value ;
536+ return str_replace (['. ' , '[ ' , '] ' ], ['_ ' , '_ ' , '' ], $ value );
541537 }
542538
543539 /**
@@ -640,7 +636,12 @@ protected function getClasses($type, array $attributes = [], $errors = null)
640636 protected function getControlErrors ($ name )
641637 {
642638 if ($ this ->session ) {
639+
643640 if ($ errors = $ this ->session ->get ('errors ' )) {
641+
642+ // Replaces to get errors on nested fields
643+ $ name = str_replace (['[ ' , '] ' ], ['. ' , '' ], $ name );
644+
644645 return $ errors ->get ($ name , []);
645646 }
646647 }
@@ -738,7 +739,7 @@ protected function doBuild($type, $name, $value = null, array $attributes = arra
738739 $ label = $ this ->getLabel ($ name , $ attributes );
739740 $ htmlName = $ this ->getHtmlName ($ name );
740741 $ id = $ this ->getHtmlId ($ name , $ attributes );
741- $ errors = $ this ->getControlErrors ($ id );
742+ $ errors = $ this ->getControlErrors ($ name );
742743 $ hasErrors = !empty ($ errors );
743744 $ customTemplate = $ this ->getCustomTemplate ($ attributes );
744745
0 commit comments