mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 21:41:19 +08:00
Fixes #15889: Fixed override yii\helpers\Html::setActivePlaceholder
This commit is contained in:
committed by
Alexander Makarov
parent
4b772f1bd0
commit
bf5476f253
@ -40,6 +40,7 @@ Yii Framework 2 Change Log
|
|||||||
- Chg #16192: `yii\db\Command::logQuery()` is now protected, extracted `getCacheKey()` from `queryInternal()` (drlibra)
|
- Chg #16192: `yii\db\Command::logQuery()` is now protected, extracted `getCacheKey()` from `queryInternal()` (drlibra)
|
||||||
- Bug #16377: Fixed `yii\base\Event:off()` undefined index error when event handler does not match (razvanphp)
|
- Bug #16377: Fixed `yii\base\Event:off()` undefined index error when event handler does not match (razvanphp)
|
||||||
- Bug #16514: Fixed `yii\di\Container::resolveCallableDependencies` to support callable object (wi1dcard)
|
- Bug #16514: Fixed `yii\di\Container::resolveCallableDependencies` to support callable object (wi1dcard)
|
||||||
|
- Bug #15889: Fixed override `yii\helpers\Html::setActivePlaceholder` (lesha724)
|
||||||
|
|
||||||
2.0.15.1 March 21, 2018
|
2.0.15.1 March 21, 2018
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|||||||
@ -1325,7 +1325,7 @@ class BaseHtml
|
|||||||
$options['id'] = static::getInputId($model, $attribute);
|
$options['id'] = static::getInputId($model, $attribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
self::setActivePlaceholder($model, $attribute, $options);
|
static::setActivePlaceholder($model, $attribute, $options);
|
||||||
|
|
||||||
return static::input($type, $name, $value, $options);
|
return static::input($type, $name, $value, $options);
|
||||||
}
|
}
|
||||||
@ -1502,7 +1502,7 @@ class BaseHtml
|
|||||||
$options['id'] = static::getInputId($model, $attribute);
|
$options['id'] = static::getInputId($model, $attribute);
|
||||||
}
|
}
|
||||||
self::normalizeMaxLength($model, $attribute, $options);
|
self::normalizeMaxLength($model, $attribute, $options);
|
||||||
self::setActivePlaceholder($model, $attribute, $options);
|
static::setActivePlaceholder($model, $attribute, $options);
|
||||||
return static::textarea($name, $value, $options);
|
return static::textarea($name, $value, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1729,6 +1729,34 @@ HTML;
|
|||||||
$this->assertContains('placeholder="Name"', $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