Add 'readOnly' spec to form field

Same as disabled except data is still posted back
This commit is contained in:
Samuel Georges 2016-09-27 16:50:52 +10:00
parent 30bb33b6ba
commit 0b345ad592
1 changed files with 10 additions and 0 deletions

View File

@ -94,6 +94,11 @@ class FormField
*/
public $required = false;
/**
* @var bool Specify if the field is read-only or not.
*/
public $readOnly = false;
/**
* @var bool Specify if the field is disabled or not.
*/
@ -266,6 +271,7 @@ class FormField
'placeholder',
'dependsOn',
'required',
'readOnly',
'disabled',
'cssClass',
'stretch',
@ -417,6 +423,10 @@ class FormField
$attributes = $attributes + ['disabled' => 'disabled'];
}
if ($position == 'field' && $this->readOnly) {
$attributes = $attributes + ['readonly' => 'readonly'];
}
return $attributes;
}