Merge pull request #23 from WinterSilence/patch-3

Fix class attribute in listBox() and dropDownList() of ActiveField
This commit is contained in:
simialbi 2021-12-09 08:22:48 +01:00 committed by GitHub
commit e22006d79d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 3 deletions

View File

@ -6,6 +6,7 @@ Yii Framework 2 bootstrap5 extension Change Log
- Enh #18: Add rangeInput(), colorInput() and switch mode to checkbox() in class ActiveField (WinterSilence) - Enh #18: Add rangeInput(), colorInput() and switch mode to checkbox() in class ActiveField (WinterSilence)
- Bug #19: Fix value of attribute "aria-current" in LinkPager::renderPageButton() (WinterSilence) - Bug #19: Fix value of attribute "aria-current" in LinkPager::renderPageButton() (WinterSilence)
- Bug #23: Fix class attribute in listBox() and dropDownList() of class ActiveField (WinterSilence)
2.0.2 October 21, 2021 2.0.2 October 21, 2021

View File

@ -431,6 +431,7 @@ class ActiveField extends \yii\widgets\ActiveField
if ($this->form->layout === ActiveForm::LAYOUT_INLINE) { if ($this->form->layout === ActiveForm::LAYOUT_INLINE) {
Html::removeCssClass($this->labelOptions, 'visually-hidden'); Html::removeCssClass($this->labelOptions, 'visually-hidden');
} }
Html::addCssClass($options, ['widget' => 'form-select']);
return parent::listBox($items, $options); return parent::listBox($items, $options);
} }
@ -443,6 +444,7 @@ class ActiveField extends \yii\widgets\ActiveField
if ($this->form->layout === ActiveForm::LAYOUT_INLINE) { if ($this->form->layout === ActiveForm::LAYOUT_INLINE) {
Html::removeCssClass($this->labelOptions, 'visually-hidden'); Html::removeCssClass($this->labelOptions, 'visually-hidden');
} }
Html::addCssClass($options, ['widget' => 'form-select']);
return parent::dropdownList($items, $options); return parent::dropdownList($items, $options);
} }
@ -520,7 +522,6 @@ class ActiveField extends \yii\widgets\ActiveField
*/ */
public function rangeInput(array $options = []) public function rangeInput(array $options = [])
{ {
Html::removeCssClass($options, 'form-control');
Html::addCssClass($options, ['widget' => 'form-range']); Html::addCssClass($options, ['widget' => 'form-range']);
return $this->input('range', $options); return $this->input('range', $options);

View File

@ -171,7 +171,7 @@ HTML;
$expected2 = <<<HTML $expected2 = <<<HTML
<div class="mb-3 field-dynamicmodel-selectname"> <div class="mb-3 field-dynamicmodel-selectname">
<label class="form-label" for="dynamicmodel-selectname">Select Name</label> <label class="form-label" for="dynamicmodel-selectname">Select Name</label>
<input type="hidden" name="DynamicModel[selectName]" value=""><select id="dynamicmodel-selectname" class="form-control" name="DynamicModel[selectName]" size="4" placeholder> <input type="hidden" name="DynamicModel[selectName]" value=""><select id="dynamicmodel-selectname" class="form-select" name="DynamicModel[selectName]" size="4" placeholder>
<option value="1">One</option> <option value="1">One</option>
<option value="2">Two</option> <option value="2">Two</option>
<option value="3">Three</option> <option value="3">Three</option>
@ -227,7 +227,7 @@ HTML;
HTML; HTML;
$expected2 = <<<HTML $expected2 = <<<HTML
<div class="form-floating mt-3 field-dynamicmodel-selectname"> <div class="form-floating mt-3 field-dynamicmodel-selectname">
<input type="hidden" name="DynamicModel[selectName]" value=""><select id="dynamicmodel-selectname" class="form-control" name="DynamicModel[selectName]" size="4" placeholder> <input type="hidden" name="DynamicModel[selectName]" value=""><select id="dynamicmodel-selectname" class="form-select" name="DynamicModel[selectName]" size="4" placeholder>
<option value="1">One</option> <option value="1">One</option>
<option value="2">Two</option> <option value="2">Two</option>
<option value="3">Three</option> <option value="3">Three</option>