本文整理汇总了PHP中yii\bootstrap\Html::getInputId方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::getInputId方法的具体用法?PHP Html::getInputId怎么用?PHP Html::getInputId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::getInputId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
echo Html::beginTag('div', ['class' => 'input-group']);
if (!isset($this->options['class'])) {
$this->options['class'] = 'form-control';
}
$iconId = 'icon-' . $this->options['id'];
if (!isset($this->options['aria-describedby'])) {
$this->options['aria-describedby'] = $iconId;
}
if ($this->hasModel()) {
$replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
}
if ($this->icon != '') {
$replace['{icon}'] = Html::tag('span', Icon::show($this->icon, [], Icon::FA), ['class' => 'input-group-addon', 'id' => $iconId]);
}
echo strtr($this->template, $replace);
echo Html::endTag('div');
$view = $this->getView();
Assets::register($view);
$idMaster = $this->hasModel() ? Html::getInputId($this->model, $this->fromField) : $this->fromField;
$idSlave = $this->options['id'];
$view->registerJs("\n \$('#{$idMaster}').syncTranslit({\n destination: '{$idSlave}',\n type: 'url',\n caseStyle: 'lower',\n urlSeparator: '-'\n });");
}
示例2: run
public function run()
{
if ($this->hasModel()) {
if (!ArrayHelper::getValue($this->options, 'id')) {
$this->options['id'] = Html::getInputId($this->model, $this->attribute);
}
echo Html::activeTextarea($this->model, $this->attribute, $this->options);
} else {
if (!ArrayHelper::getValue($this->options, 'id')) {
$this->options['id'] = Html::getAttributeName($this->name . rand(1, 9999));
}
echo Html::textarea($this->name, $this->value, $this->options);
}
$this->registerAssets();
}