Skip to content

Commit 0bff7ed

Browse files
committed
RadioList::getLabelPart() uses $itemLabel instead of $label
1 parent a3600d1 commit 0bff7ed

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/Forms/Controls/RadioList.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct($label = NULL, array $items = NULL)
4343
$this->control->type = 'radio';
4444
$this->container = Html::el();
4545
$this->separator = Html::el('br');
46-
$this->itemLabel = Html::el();
46+
$this->itemLabel = Html::el('label');
4747
$this->setOption('type', 'radio');
4848
}
4949

@@ -110,8 +110,9 @@ public function getControlPart($key = NULL)
110110
*/
111111
public function getLabelPart($key = NULL)
112112
{
113+
$itemLabel = clone $this->itemLabel;
113114
return func_num_args()
114-
? parent::getLabel($this->items[$key])->for($this->getHtmlId() . '-' . $key)
115+
? $itemLabel->setText($this->translate($this->items[$key]))->for($this->getHtmlId() . '-' . $key)
115116
: $this->getLabel();
116117
}
117118

tests/Forms/Controls.RadioList.render.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ test(function () { // item label prototype
152152
]);
153153
$input->getItemLabelPrototype()->class('foo');
154154

155+
Assert::same('<label></label>', (string) $input->getLabel());
156+
Assert::same('<label class="foo" for="frm-list-a">b</label>', (string) $input->getLabelPart('a'));
155157
Assert::same('<label class="foo"><input type="radio" name="list" value="a">b</label>', (string) $input->getControl());
156158
});
157159

0 commit comments

Comments
 (0)