@@ -79,8 +79,21 @@ public function getExtraAttributes(View $view)
7979
8080 $ valueRequiredBooleans = ['data-allow-clear ' ];
8181
82+ return $ this ->mapAttributesToString ($ extra , $ valueRequiredBooleans );
83+
84+ }
85+
86+ public function getContainerAttributes (View $ view )
87+ {
88+ $ extra = $ view ->offsetExists ('container ' ) ? $ view ->offsetGet ('container ' ) : [];
89+ return $ this ->mapAttributesToString ($ extra );
90+
91+ }
92+
93+ protected function mapAttributesToString ($ attributes , $ valueRequiredBooleans = []) {
94+
8295 // Convert extra properties to key="value" string
83- $ attributes = array_map (function ($ key , $ value ) use ($ valueRequiredBooleans ) {
96+ $ output = array_map (function ($ key , $ value ) use ($ valueRequiredBooleans ) {
8497 // ['required']
8598 if (is_int ($ key ) || is_string ($ key ) && ctype_digit ($ key )) {
8699 return in_array ($ value , $ valueRequiredBooleans ) ? "{$ value }= \"1 \"" : $ value ;
@@ -100,14 +113,14 @@ public function getExtraAttributes(View $view)
100113 if (is_object ($ value ) || is_array ($ value )) {
101114 $ value = json_encode ($ value );
102115 }
103-
116+
104117 return sprintf ('%s="%s" ' , $ key , htmlspecialchars ($ value ));
105- }, array_keys ($ extra ), $ extra );
118+ }, array_keys ($ attributes ), $ attributes );
106119
107120 // Remove empty (boolean false) attributes
108- $ attributes = array_filter ($ attributes );
121+ $ output = array_filter ($ output );
109122
110- return implode (' ' , $ attributes );
123+ return implode (' ' , $ output );
111124 }
112125
113126 public function getFieldTemplate (View $ view )
0 commit comments