choicefield

Translate select options in Symfony2 class forms

佐手、 提交于 2019-11-27 05:35:53
问题 I'm using a class form in Symfony2 Beta3 as follows: namespace Partners\FrontendBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; class ConfigForm extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder->add('no_containers', 'choice', array('choices' => array(1 => 'yes', 0 => 'no'))); ... I want to translate the 'yes' and 'no' options, but I don't know how to use the translator here. 回答1: You can use the