Skip to content

Commit f79093b

Browse files
committed
CheckboxList: removed compatibility workaround for label vs item label (BC break)
1 parent 4264dcd commit f79093b

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
@@ -42,7 +42,7 @@ public function __construct($label = NULL, array $items = NULL)
4242
$this->control->type = 'checkbox';
4343
$this->container = Html::el();
4444
$this->separator = Html::el('br');
45-
// $this->itemLabel = Html::el('label'); back compatiblity
45+
$this->itemLabel = Html::el('label');
4646
$this->setOption('type', 'checkbox');
4747
}
4848

@@ -67,7 +67,7 @@ public function getControl()
6767
'required' => NULL,
6868
'data-nette-rules:' => [key($items) => $input->attrs['data-nette-rules']],
6969
]),
70-
$this->itemLabel ? $this->itemLabel->attrs : $this->label->attrs,
70+
$this->itemLabel->attrs,
7171
$this->separator
7272
)
7373
);
@@ -106,7 +106,7 @@ public function getControlPart($key = NULL)
106106
*/
107107
public function getLabelPart($key = NULL)
108108
{
109-
$itemLabel = $this->itemLabel ? clone $this->itemLabel : clone $this->label;
109+
$itemLabel = clone $this->itemLabel;
110110
return func_num_args()
111111
? $itemLabel->setText($this->translate($this->items[$key]))->for($this->getHtmlId() . '-' . $key)
112112
: $this->getLabel();
@@ -139,7 +139,7 @@ public function getContainerPrototype()
139139
*/
140140
public function getItemLabelPrototype()
141141
{
142-
return $this->itemLabel ?: $this->itemLabel = Html::el('label');
142+
return $this->itemLabel;
143143
}
144144

145145
}

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)