Skip to content

Commit

Permalink
Unset maxlength in textarea (#4219)
Browse files Browse the repository at this point in the history
  • Loading branch information
dafeder authored Jul 10, 2024
1 parent ff7a404 commit 6d55543
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions modules/json_form_widget/src/WidgetRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public function handleUploadOrLinkElement(mixed $spec, array $element) {
*/
public function handleTextareaElement(mixed $spec, array $element) {
$element['#type'] = 'textarea';
unset($element['#maxlength']);
if (isset($spec->rows)) {
$element['#rows'] = $spec->rows;
}
Expand Down
40 changes: 39 additions & 1 deletion modules/json_form_widget/tests/src/Unit/WidgetRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,47 @@ private function getContainerChain() {
->add(MetastoreService::class, 'getAll', $metastoreGetAllOptions);
}

/**
* Data provider.
*
* Each dataset gets is an array with three elements:
* 1. The spec object.
* 2. The element array.
* 3. The expected handled element array.
*/
public static function dataProvider(): array {
return [
// Tag field is a free-tagging autocomplete that populates from metastore.
// Ensure regular textfield with maxlength comes through.
'textField' => [
(object) [
'widget' => 'textfield',
],
[
'#type' => 'textfield',
'#title' => 'textField',
'#maxlength' => 256,
],
[
'#type' => 'textfield',
'#title' => 'textField',
'#maxlength' => 256,
],
],
// Textarea should not have maxlength after being handled.
'textArea' => [
(object) [
'widget' => 'textarea',
],
[
'#type' => 'textfield',
'#title' => 'textArea',
'#maxlength' => 256,
],
[
'#type' => 'textarea',
'#title' => 'textArea',
],
],
'tagField' => [
(object) [
'widget' => 'list',
Expand Down

0 comments on commit 6d55543

Please sign in to comment.