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 });"); }
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(); }