diff --git a/ActiveField.php b/ActiveField.php index 0deaa7d05..838fe5754 100644 --- a/ActiveField.php +++ b/ActiveField.php @@ -206,7 +206,6 @@ public function checkbox($options = [], $enclosedByLabel = true) if ($this->form->layout === 'horizontal') { Html::addCssClass($this->wrapperOptions, $this->horizontalCssClasses['offset']); } - $this->labelOptions['class'] = null; } return parent::checkbox($options, false); diff --git a/tests/ActiveFieldTest.php b/tests/ActiveFieldTest.php index 93c521707..f5ea70c85 100644 --- a/tests/ActiveFieldTest.php +++ b/tests/ActiveFieldTest.php @@ -110,4 +110,30 @@ public function testCheckboxListItemOptions() $this->assertContains('data-attribute="test"', $content); } -} \ No newline at end of file + + public function testCheckboxOptionsLabelClass() + { + $className = 'test-class'; + + $this->activeField->labelOptions = [ + 'class' => $className, + ]; + $content = $this->activeField->checkbox()->render(); + + $this->assertContains("class=\"{$className}\"", $content); + } + + public function testCheckboxLabelOptionsClass() + { + $className = 'test-class'; + + $content = $this->activeField->checkbox([ + 'label' => 'test-label', + 'labelOptions' => [ + 'class' => $className, + ], + ])->render(); + + $this->assertContains("class=\"{$className}\"", $content); + } +}