Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to extract translation id for form label with JMS Translation Bundle
    primarykey
    data
    text
    <p>I'm using the JMS Translation Bundle to extract my translations. Everything works, but when I try to extract my translation messages form a form builder I recieve following message:</p> <pre><code>[JMS\TranslationBundle\Exception\RuntimeException] Unable to extract translation id for form label from non-string values, but got "PHPParser_Node_Expr_MethodCall" in /srv/local.project.com/app/../src/Project/MyBundleBundle/Form/Type/EmailType .php on line 30. Please refactor your code to pass a string, or add "/** @Ignore */". </code></pre> <p>The code I use for it is as followed:</p> <pre><code>public function __construct($translator) { //translation service passed from controller $this-&gt;trans = $translator; } public function buildForm(FormBuilderInterface $builder, array $options) { $builder-&gt;add('email', 'repeated', array( 'type' =&gt; 'email', 'first_name' =&gt; 'email', 'second_name' =&gt; 'email-repeat', //TRANSLATION GIVES ERROR ON NEXT LINE 'invalid_message' =&gt; $this-&gt;trans-&gt;trans('online.form.email.errors.equal', array(), 'messages_roadrunner'), 'error_bubbling' =&gt; true, 'first_options' =&gt; array('label' =&gt; $this-&gt;trans-&gt;trans("online.form.email.fields.one", array(), 'messages_roadrunner')), 'second_options' =&gt; array('label' =&gt; $this-&gt;trans-&gt;trans("online.form.email.fields.second", array(), 'messages_roadrunner')), ) ); $builder-&gt;add('optin', 'checkbox', array( 'required' =&gt; false, 'label' =&gt; $this-&gt;trans-&gt;trans('online.form.email.fields.optin', array(), 'messages_roadrunner') )); } </code></pre> <p>The strange thing is that in my controller I use the same thing, but there everything works as normal:</p> <pre><code>$content['text'] = $this-&gt;get('translator')-&gt;trans('online.tariff.text.no_advice', array(), 'messages_roadrunner'); </code></pre> <p>Does anyone have any experience with this problem?</p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload