Answer the question
In order to leave comments, you need to log in
Yii2 ActiveField how to add new {tag} to template?
Hello. Is it possible to add your own {tag} to the template without severe hemorrhoids?
There is a code, you need to add {icon}, and assign it by field(...)->icon('clock'), for example.
$form = ActiveForm::begin([
'id' => 'login-form',
'action' => '/login',
'options' => ['class' => 'form-horizontal'],
'fieldConfig' => [
'template' => "<div class=\"col-lg-12\">
<span class=\"fa fa-{icon} input-icon\"></span>
{input}
</div>\n<div class=\"col-lg-12\">{error}</div>",
],
]);
Answer the question
In order to leave comments, you need to log in
Goodnight.
What do you mean by "strong hemorrhoids"?
The ActiveField class has a public function render() method
public function render($content = null)
{
if ($content === null) {
if (!isset($this->parts['{input}'])) {
$this->textInput();
}
if (!isset($this->parts['{label}'])) {
$this->label();
}
if (!isset($this->parts['{error}'])) {
$this->error();
}
if (!isset($this->parts['{hint}'])) {
$this->hint(null);
}
$content = strtr($this->template, $this->parts);
} elseif (!is_string($content)) {
$content = call_user_func($content, $this);
}
return $this->begin() . "\n" . $content . "\n" . $this->end();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question