From 0b345ad5922c2ce0ca9ccd4ce1df1d10212008aa Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Tue, 27 Sep 2016 16:50:52 +1000 Subject: [PATCH] Add 'readOnly' spec to form field Same as disabled except data is still posted back --- modules/backend/classes/FormField.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/backend/classes/FormField.php b/modules/backend/classes/FormField.php index 6428904f2..36a0dab75 100644 --- a/modules/backend/classes/FormField.php +++ b/modules/backend/classes/FormField.php @@ -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; }