@@ -91,9 +91,9 @@ class FormField
9191 public $ span = 'full ' ;
9292
9393 /**
94- * @var string Specifies a size. Possible values: tiny, small, large, huge, giant.
94+ * @var string|int Specifies a size. Possible values for textarea : tiny, small, large, huge, giant.
9595 */
96- public $ size = ' large ' ;
96+ public $ size ;
9797
9898 /**
9999 * @var string Specifies contextual visibility of this form field.
@@ -211,7 +211,7 @@ public function span($value = 'full')
211211 }
212212
213213 /**
214- * Sets a side of the field on a form.
214+ * Sets the size of the field on a form.
215215 * @param string $value Specifies a size. Possible values: tiny, small, large, huge, giant
216216 */
217217 public function size ($ value = 'large ' )
@@ -259,6 +259,11 @@ public function options($value = null)
259259 */
260260 public function displayAs ($ type , $ config = [])
261261 {
262+ if (in_array ($ type , ['textarea ' , 'widget ' ])) {
263+ // defaults to 'large'
264+ $ this ->size = 'large ' ;
265+ }
266+
262267 $ this ->type = strtolower ($ type ) ?: $ this ->type ;
263268 $ this ->config = $ this ->evalConfig ($ config );
264269
@@ -281,18 +286,18 @@ protected function evalConfig($config)
281286 */
282287 $ applyConfigValues = [
283288 'commentHtml ' ,
284- 'placeholder ' ,
289+ 'context ' ,
290+ 'cssClass ' ,
285291 'dependsOn ' ,
286- 'required ' ,
287- 'readOnly ' ,
288292 'disabled ' ,
289- 'cssClass ' ,
290- 'stretch ' ,
291- 'context ' ,
292293 'hidden ' ,
293- 'trigger ' ,
294- 'preset ' ,
295294 'path ' ,
295+ 'placeholder ' ,
296+ 'preset ' ,
297+ 'readOnly ' ,
298+ 'required ' ,
299+ 'stretch ' ,
300+ 'trigger ' ,
296301 ];
297302
298303 foreach ($ applyConfigValues as $ value ) {
@@ -729,4 +734,31 @@ protected function getFieldNameFromData($fieldName, $data, $default = null)
729734
730735 return $ result ;
731736 }
737+
738+ /**
739+ * Implements the getter functionality.
740+ * @param string $name
741+ */
742+ public function __get ($ name )
743+ {
744+ if (is_array ($ this ->config ) && array_key_exists ($ name , $ this ->config )) {
745+ return array_get ($ this ->config , $ name );
746+ }
747+ if (property_exists ($ this , $ name )) {
748+ return $ this ->{$ name };
749+ }
750+ return null ;
751+ }
752+
753+ /**
754+ * Determine if an attribute exists on the object.
755+ * @param string $name
756+ */
757+ public function __isset ($ name )
758+ {
759+ if (is_array ($ this ->config ) && array_key_exists ($ name , $ this ->config )) {
760+ return true ;
761+ }
762+ return property_exists ($ this , $ name ) && !is_null ($ this ->{$ name });
763+ }
732764}
0 commit comments