Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of checkbox ActiveField label class name #203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ActiveField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 27 additions & 1 deletion tests/ActiveFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,30 @@ public function testCheckboxListItemOptions()

$this->assertContains('data-attribute="test"', $content);
}
}

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);
}
}