我正在尝试在Symfony(2.7)中创建自定义表单类型,以便为我的某些表单字段添加help_block(Boostrap 3样式).
我按照此页面说明操作:http://symfony.com/doc/current/cookbook/form/create_form_type_extension.html
显示没问题,help_block工作正常,但它不可翻译,(dev栏没有显示任何缺失的翻译).所以我的问题是:如何使自定义表单类型可翻译,如标签选项,如果可能,在与表单相同的translation_domain中?
这是扩展代码:
<?php
namespace WIC\MasterBundle\Form\Extension;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\PropertyAccess\PropertyAccess;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* Add a BootStrap Help block to any form field
*/
class HelpTextExtension extends AbstractTypeExtension
{
/**
* Returns the name of the type being extended.
*
* @return string The name of the type being extended
*/
public function getExtendedType() {
return 'form';
}
/**
* Add the help_text option
*
* @param OptionsResolver …Run Code Online (Sandbox Code Playgroud)