Skip to content

Commit a9df17e

Browse files
author
Christian Leucht
committed
Element // fix attributesForView to return correct "disabled"-state in case the parent is disabled.
View\FormRow // add new selector "form-row--is-disabled".
1 parent 7bdbb76 commit a9df17e

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/Element/Element.php

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public function attributesForView(): array
150150
$id = $parentAttributes['id'];
151151
$name = $parentAttributes['name'];
152152

153+
$attributes['disabled'] = $this->isDisabled();
153154
$attributes['id'] = $id . '_' . $attributes['id'];
154155
$attributes['name'] = $name . '[' . $attributes['name'] . ']';
155156
}

src/View/FormRow.php

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ public function render(ElementInterface $element): string
8383
if ($errors !== '') {
8484
$rowAttributes['class'] .= ' form-row--has-errors';
8585
}
86+
if ($element->isDisabled()) {
87+
$rowAttributes['class'] .= 'form-row--is-disabled';
88+
}
8689
if ($element->type() === 'hidden') {
8790
$rowAttributes['class'] .= ' hidden';
8891
}

tests/phpunit/Unit/View/FormTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function testRender(): void
5656
->andReturn('text');
5757
$element_stub->allows('attributesForView')
5858
->andReturn([]);
59+
$element_stub->allows('isDisabled')
60+
->andReturnFalse();
5961

6062
$form_stub = Mockery::mock(FormInterface::class, ElementInterface::class, CollectionElementInterface::class);
6163
$form_stub->allows('name')

0 commit comments

Comments
 (0)