Skip to content

Commit 48efa1d

Browse files
committed
CheckboxList: removed compatibility workaround for label vs item label (BC break)
1 parent 62ef303 commit 48efa1d

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/Forms/Controls/CheckboxList.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct($label = NULL, array $items = NULL)
4141
$this->control->type = 'checkbox';
4242
$this->container = Html::el();
4343
$this->separator = Html::el('br');
44-
// $this->itemLabel = Html::el('label'); back compatiblity
44+
$this->itemLabel = Html::el('label');
4545
$this->setOption('type', 'checkbox');
4646
}
4747

@@ -65,7 +65,7 @@ public function getControl(): Html
6565
'required' => NULL,
6666
'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']],
6767
]),
68-
$this->itemLabel ? $this->itemLabel->attrs : $this->label->attrs,
68+
$this->itemLabel->attrs,
6969
$this->separator
7070
)
7171
);
@@ -97,7 +97,7 @@ public function getControlPart($key = NULL): Html
9797

9898
public function getLabelPart($key = NULL): Html
9999
{
100-
$itemLabel = $this->itemLabel ? clone $this->itemLabel : clone $this->label;
100+
$itemLabel = clone $this->itemLabel;
101101
return func_num_args()
102102
? $itemLabel->setText($this->translate($this->items[$key]))->for($this->getHtmlId() . '-' . $key)
103103
: $this->getLabel();
@@ -127,7 +127,7 @@ public function getContainerPrototype(): Html
127127
*/
128128
public function getItemLabelPrototype(): Html
129129
{
130-
return $this->itemLabel ?: $this->itemLabel = Html::el('label');
130+
return $this->itemLabel;
131131
}
132132

133133
}

tests/Forms/Controls.CheckboxList.render.phpt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,3 @@ test(function () { // item label prototype
192192
Assert::same('<label class="foo" for="frm-list-a">b</label>', (string) $input->getLabelPart('a'));
193193
Assert::same('<label class="foo"><input type="checkbox" name="list[]" value="a">b</label>', (string) $input->getControl());
194194
});
195-
196-
197-
test(function () { // item label prototype (back compatiblity)
198-
$form = new Form;
199-
$input = $form->addCheckboxList('list', NULL, [
200-
'a' => 'b',
201-
]);
202-
$input->getLabelPrototype()->class('foo');
203-
204-
Assert::same('<label class="foo"></label>', (string) $input->getLabel());
205-
Assert::same('<label class="foo" for="frm-list-a">b</label>', (string) $input->getLabelPart('a'));
206-
Assert::same('<label class="foo"><input type="checkbox" name="list[]" value="a">b</label>', (string) $input->getControl());
207-
});

0 commit comments

Comments
 (0)