symfony - Unable to extract translation id for form label with JMS Translation Bundle -


i'm using jms translation bundle extract translations. works, when try extract translation messages form form builder recieve following message:

[jms\translationbundle\exception\runtimeexception]   unable extract translation id form label non-string values, got "phpparser_node_expr_methodcall" in /srv/local.project.com/app/../src/project/mybundlebundle/form/type/emailtype   .php on line 30. please refactor code pass string, or add "/** @ignore */". 

the code use followed:

public function __construct($translator)     {         //translation service passed controller         $this->trans = $translator;     }      public function buildform(formbuilderinterface $builder, array $options)     {         $builder->add('email', 'repeated', array(                 'type' => 'email',                 'first_name' => 'email',                 'second_name' => 'email-repeat',                  //translation gives error on next line                           'invalid_message' => $this->trans->trans('online.form.email.errors.equal', array(), 'messages_roadrunner'),                  'error_bubbling' => true,                 'first_options'  => array('label' => $this->trans->trans("online.form.email.fields.one", array(), 'messages_roadrunner')),                 'second_options' => array('label' => $this->trans->trans("online.form.email.fields.second", array(), 'messages_roadrunner')),             )         );          $builder->add('optin', 'checkbox', array(             'required'  => false,             'label' => $this->trans->trans('online.form.email.fields.optin', array(), 'messages_roadrunner')         ));      } 

the strange thing in controller use same thing, there works normal:

$content['text'] = $this->get('translator')->trans('online.tariff.text.no_advice', array(), 'messages_roadrunner'); 

does have experience problem?

thanks in advance!

don't forget default extractor configured automatically extract values formbuilder::add() call arguments (see doc). in case expects 'label' string, contains method call, , there goes error.

this means don't have pass translator formtype too.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -