我找到了很好的解决方案,但不幸的是Zend2返回错误
溶液: Button content in ZF2 forms
错误:
Zend \ View \ HelperPluginManager :: createFromInvokable:检索失败 “formbutton(别名:formbutton)”通过invokable类 “MyModule的\表格\查看\助手\ FormButton”;类不存在
在MyModule \ Form \ View \ Helper \ FormButton中我创建了FormButton.php:
use Zend\Form\View\Helper\FormButton as ZendFormButton;
class FormButton extends ZendFormButton
{
public function render(ElementInterface $element, $buttonContent = null)
{
$content = (isset($buttonContent)) ? $buttonContent : $element->getLabel();
$icon = isset($element->getOption('icon')) ? $element->getOption('icon') : '';
$escape = $this->getEscapeHtmlHelper();
return $this->openTag($element).$icon.$escape($content).$this->closeTag();
}
}
和Module.php:
public function getViewHelperConfig()
{
return array(
'invokables' => array(
'form_button' => 'MyModule\Form\View\Helper\FormButton',
)
);
}
$this->add(array(
'type' => 'Button',
'name' => 'submit',
'options' => array(
'label' => 'Modifica',
'icon' => '<i class="icon icon-foo">',
),
'attributes' => array(
'type' => 'submit',
'class' => 'btn btn-warning'
)
));
答案 0 :(得分:0)
希望这会对你有所帮助。将disable_html_escape
标记值用作true
。
$this->form->add(array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'agreement_point',
'options' => array(
'label' => $this->getTranslatorHelper()->translate('Ich akzeptiere die <a class="first-agreement">Allgemeinen Geschäftsbedingunge</a>, die <a class="second-agreement">Wiederrufsbedingungen</a> und'),
'label_options' => array(
'disable_html_escape' => true,
),
)
));