fixed placeholder rendering in floating forms

This commit is contained in:
Simon Karlen 2021-08-03 11:05:04 +02:00
parent 8d2a2713ce
commit c3c1bb2eba
No known key found for this signature in database
GPG Key ID: 0630C27D666EBCC3
2 changed files with 3 additions and 2 deletions

View File

@ -519,6 +519,7 @@ class ActiveField extends \yii\widgets\ActiveField
Html::addCssClass($config['labelOptions'], ['screenreader' => 'visually-hidden']); Html::addCssClass($config['labelOptions'], ['screenreader' => 'visually-hidden']);
} elseif ($layout === ActiveForm::LAYOUT_FLOATING) { } elseif ($layout === ActiveForm::LAYOUT_FLOATING) {
$config['inputOptions']['placeholder'] = true;
$config['template'] = "{input}\n{label}\n{error}\n{hint}"; $config['template'] = "{input}\n{label}\n{error}\n{hint}";
Html::addCssClass($config['options'], ['layout' => 'form-floating mt-3']); Html::addCssClass($config['options'], ['layout' => 'form-floating mt-3']);
} }

View File

@ -229,7 +229,7 @@ HTML;
$expected = <<<HTML $expected = <<<HTML
<div class="form-floating mt-3 field-dynamicmodel-attributename"> <div class="form-floating mt-3 field-dynamicmodel-attributename">
<input type="text" id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]"> <input type="text" id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]" placeholder="Attribute Name">
<label class="form-label" for="dynamicmodel-attributename">Attribute Name</label> <label class="form-label" for="dynamicmodel-attributename">Attribute Name</label>
<div class="invalid-feedback"></div> <div class="invalid-feedback"></div>
@ -237,7 +237,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"> <input type="hidden" name="DynamicModel[selectName]" value=""><select id="dynamicmodel-selectname" class="form-control" 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>