Pass autofocus flag to front-end

This commit is contained in:
Saophalkun Ponlu 2017-05-16 10:52:15 +12:00
parent 7a8dfd2785
commit a975b88661
4 changed files with 40 additions and 1 deletions

View File

@ -169,6 +169,11 @@ class FormField extends RequestHandler
*/ */
protected $disabled = false; protected $disabled = false;
/**
* @var bool
*/
protected $autofocus = false;
/** /**
* Custom validation message for the field. * Custom validation message for the field.
* *
@ -716,7 +721,8 @@ class FormField extends RequestHandler
'class' => $this->extraClass(), 'class' => $this->extraClass(),
'id' => $this->ID(), 'id' => $this->ID(),
'disabled' => $this->isDisabled(), 'disabled' => $this->isDisabled(),
'readonly' => $this->isReadonly() 'readonly' => $this->isReadonly(),
'autofocus' => $this->isAutofocus()
); );
if ($this->Required()) { if ($this->Required()) {
@ -1222,6 +1228,25 @@ class FormField extends RequestHandler
return $this; return $this;
} }
/**
* @return bool
*/
public function isAutofocus() {
return $this->autofocus;
}
/**
* Sets a autofocus flag on this FormField.
*
* @param bool $autofocus
* @return $this
*/
public function setAutofocus($autofocus)
{
$this->autofocus = $autofocus;
return $this;
}
/** /**
* Returns a read-only version of this field. * Returns a read-only version of this field.
* *
@ -1560,6 +1585,7 @@ class FormField extends RequestHandler
'customValidationMessage' => $this->getCustomValidationMessage(), 'customValidationMessage' => $this->getCustomValidationMessage(),
'validation' => $this->getSchemaValidation(), 'validation' => $this->getSchemaValidation(),
'attributes' => [], 'attributes' => [],
'autoFocus' => $this->isAutofocus(),
'data' => [], 'data' => [],
]; ];
} }

View File

@ -28,6 +28,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": [], "attributes": [],
"data": [], "data": [],
@ -48,6 +49,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": [], "attributes": [],
"data": [], "data": [],
@ -70,6 +72,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": { "attributes": {
"type": "submit" "type": "submit"
@ -94,6 +97,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": { "attributes": {
"type": "button" "type": "button"
@ -118,6 +122,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": null, "readOnly": null,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": [], "attributes": [],
"data": { "data": {
@ -149,6 +154,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": { "attributes": {
"type": "submit" "type": "submit"
@ -173,6 +179,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": { "attributes": {
"type": "submit" "type": "submit"

View File

@ -28,6 +28,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"attributes": [], "attributes": [],
"data": [], "data": [],

View File

@ -28,6 +28,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"validation": { "validation": {
"required": true, "required": true,
@ -54,6 +55,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"validation": { "validation": {
"date": true "date": true
@ -80,6 +82,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"validation": { "validation": {
"numeric": true "numeric": true
@ -102,6 +105,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"validation": { "validation": {
"currency": true "currency": true
@ -124,6 +128,7 @@
"leftTitle": null, "leftTitle": null,
"readOnly": false, "readOnly": false,
"disabled": false, "disabled": false,
"autoFocus": false,
"customValidationMessage": "", "customValidationMessage": "",
"validation": [], "validation": [],
"attributes": [], "attributes": [],