Fixes #15889: Fixed override yii\helpers\Html::setActivePlaceholder

This commit is contained in:
Alexey
2018-07-28 19:07:09 +03:00
committed by Alexander Makarov
parent 4b772f1bd0
commit bf5476f253
3 changed files with 31 additions and 2 deletions

View File

@ -1729,6 +1729,34 @@ HTML;
$this->assertContains('placeholder="Name"', $html);
}
public function testOverrideSetActivePlaceholder()
{
$model = new HtmlTestModel();
$html = MyHtml::activeTextInput($model, 'name', ['placeholder' => true]);
$this->assertContains('placeholder="My placeholder: Name"', $html);
}
}
/**
* Class MyHtml
* @package yiiunit\framework\helpers
*/
class MyHtml extends Html{
/**
* @param \yii\base\Model $model
* @param string $attribute
* @param array $options
*/
protected static function setActivePlaceholder($model, $attribute, &$options = [])
{
if (isset($options['placeholder']) && $options['placeholder'] === true) {
$attribute = static::getAttributeName($attribute);
$options['placeholder'] = 'My placeholder: '. $model->getAttributeLabel($attribute);
}
}
}
/**