diff --git a/src/Forms/TextareaField.php b/src/Forms/TextareaField.php index 6f0b0dd64..77b5b8ea2 100644 --- a/src/Forms/TextareaField.php +++ b/src/Forms/TextareaField.php @@ -134,16 +134,22 @@ class TextareaField extends FormField */ public function getAttributes() { - return array_merge( + $attributes = array_merge( parent::getAttributes(), array( 'rows' => $this->getRows(), 'cols' => $this->getColumns(), 'value' => null, 'type' => null, - 'maxlength' => $this->getMaxLength(), ) ); + + $maxLength = $this->getMaxLength(); + if($maxLength) { + $attributes['maxlength'] = $maxLength; + } + + return $attributes; } diff --git a/tests/php/Forms/FormSchemaTest/testGetNestedSchema.json b/tests/php/Forms/FormSchemaTest/testGetNestedSchema.json index 6e6b70118..8386f140c 100644 --- a/tests/php/Forms/FormSchemaTest/testGetNestedSchema.json +++ b/tests/php/Forms/FormSchemaTest/testGetNestedSchema.json @@ -31,7 +31,9 @@ "autoFocus": false, "customValidationMessage": "", "attributes": [], - "data": [], + "data": { + "maxlength": null + }, "validation": [] }, { diff --git a/tests/php/Forms/FormSchemaTest/testSchemaValidation.json b/tests/php/Forms/FormSchemaTest/testSchemaValidation.json index 9e6835eb8..e7f3bc3d0 100644 --- a/tests/php/Forms/FormSchemaTest/testSchemaValidation.json +++ b/tests/php/Forms/FormSchemaTest/testSchemaValidation.json @@ -30,7 +30,6 @@ "disabled": false, "autoFocus": false, "customValidationMessage": "", - "maxLength": 40, "validation": { "required": true, "max": { @@ -38,7 +37,9 @@ } }, "attributes": [], - "data": [] + "data": { + "maxlength": 40 + } }, { "name": "Date", @@ -65,7 +66,8 @@ "data": { "html5": true, "min": null, - "max": null + "max": null, + "maxlength": null } }, { @@ -89,7 +91,9 @@ "numeric": true }, "attributes": [], - "data": [] + "data": { + "maxlength": null + } }, { "name": "Money", @@ -112,7 +116,9 @@ "currency": true }, "attributes": [], - "data": [] + "data": { + "maxlength": null + } }, { "name": "SecurityID",