Код: Выделить всё
class CustomForm extends FormBase
{
// ...
$customfield = new Numeric('customfield');
$customfield->setLabel(ucwords($translations['keyi18n']) . ' [i][/i]');
$this->add($customfield);
// ...
}
< /code>
В нашем шаблоне Volt мы отображаем форму следующим образом: < /p>
{{ form.label('customfield', ['class':'customclass']) }}
{{ form.render('customfield', ['class':'customclass']) }}
Код: Выделить всё
keyi18n <span title="Lorem" class="gv-tip"> <i class=" fas fa-info-circle"></i></span>
< /code>
Вещи, которые мы пробовали: < /p>
Включение /отключение режима Volt AutoScape < /li>
Использование Tag :: setAutoScape (false); В Volt View < /li>
< /ul>
Как правильно отобразить метку с Unescaped HTML? Вот метод, который я добавил в свой класс формы: < /p>
public function labelHtml($name, array $attributes = [])
{
$element = $this->get($name);
$tagFactory = $this->getTagFactory() ?? new \Phalcon\Html\TagFactory(new \Phalcon\Html\Escaper());
$internalAttributes = $element->getAttributes();
$name = $internalAttributes["id"] ?? $element->getName();
if (!isset($attributes["for"])) {
$attributes["for"] = $name;
}
// Use the defined label or fallback to the name
$labelName = $element->getLabel();
if (!($labelName || is_numeric($labelName))) {
$labelName = $name;
}
// The third parameter "true" disables escaping
$code = ($tagFactory->newInstance("label"))($labelName, $attributes, true);
return $code;
}
< /code>
Затем в моем шаблоне Volt я заменил форму по умолчанию.{{ form.labelHtml('customfield', ['class':'customclass']) }}
Подробнее здесь: https://stackoverflow.com/questions/794 ... orm-labels
Мобильная версия