Skip to content

Commit

Permalink
Merge branch '6' into 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Feb 23, 2025
2 parents 1edc4db + 4e28aa2 commit 77061c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion code/Model/EditableFormField/EditableTextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace SilverStripe\UserForms\Model\EditableFormField;

use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldGroup;
use SilverStripe\Forms\FieldList;
Expand Down Expand Up @@ -182,7 +183,7 @@ protected function updateFormField($field)
}

if (is_numeric($this->MaxLength) && $this->MaxLength > 0) {
if ($field instanceof TextField) {
if (ClassInfo::hasMethod($field, 'setMaxLength')) {
$field->setMaxLength((int) $this->MaxLength);
}
$field->setAttribute('data-rule-maxlength', (int) $this->MaxLength);
Expand Down
2 changes: 1 addition & 1 deletion tests/php/Model/EditableFormFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function testLengthRange()
// textarea
$textField->Rows = 3;
$attributes = $textField->getFormField()->getAttributes();
$this->assertFalse(isset($attributes['maxLength']));
$this->assertEquals(20, $attributes['maxlength']);
$this->assertEquals(10, $attributes['data-rule-minlength']);
$this->assertEquals(20, $attributes['data-rule-maxlength']);
}
Expand Down

0 comments on commit 77061c6

Please sign in to comment.