mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 11:39:41 +08:00
Fixes #15889: Fixed override yii\helpers\Html::setActivePlaceholder
This commit is contained in:
committed by
Alexander Makarov
parent
4b772f1bd0
commit
bf5476f253
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user