symfony - i18n Form translations with knp Doctrine extension -


I'm using "" to translate the institutions so far I'm working great now I I have come to be a common solution, which works for any kind of languages, so I would like to use an embedded form (collection) though managed for a single unit. Now apart from adding all the new translations, it is working also that translatable_id not being set up. Has anybody tried to achieve this? I was just thinking that there is an easy way to do this, to avoid things from the confusion.

So far, very good, here are my types so that you can understand architecture better.

type type = Add ('name', 'text', array ('label' = & gt; 'name')) - & gt; Added 'allow_delete' = & gt; false, 'Allow_add' = & gt; wrong, 'label' = & gt; false, 'allow_add' = & gt; 'translation', 'collection', array ('type' = & gt; new link translation location () Gt; true)); } Public Function Set Default Options (OptionsResolverInterface $ resolver) {$ resolver- & gt; Set Defaults (array ('data_class' = & gt; 'MyBundle \ Entity \ Link')); }}

This is a duplicate language that is provided in the form of "one line" per language: en_EN anchor http // url / en

  Class Link Transposition type extends AbstractType so far {Public function buildForm (FormBuilderInterface $ builder, array $ option) {$ builder - & gt; Plus ('locale', 'lesson', array ('label' => anchor)) - & gt; Addition ('linktext', 'text', array ('label' = & gt; 'anchor')) - & gt; Plus ('linkUrl', 'text', array ('label' = & gt; 'url')); } Public Function Set Default Options (OptionsResolverInterface $ Resolver) {$ resolver- & gt; Set Defaults (array ('data_class' = & gt; 'MyBundle \ Entity \ LinkTranslation')); }}  

For example, trying to add this new entry: en_EN anchor http // url / en

I am getting:

  id translatable_id linkText linkUrl locale 7 NULL anchor http // url / en en_EN  

I've discovered how translatable_id works, but still to check There was no time for the entire source at the end, I tried to set the Transatlad ID even without better luck. (Updated: In comments)

By now I could:

  • Enter a new link # 1, but do not translate (they save with zero as trallableable_id
  • The # 2 Save existing translations link works perfectly

Some other notes for adding some references:

1 I tried:

  $ link = new link (); If ($ form-> isValid ()) {$ link- & gt; Mareu translation (); // but it also adds the ID for translation)  

2 to save current translation I still pass the existing link unit in the form builder

3 I know that I could loop and could provide the original unit

to translatable elements, but this is a hack If I have better options:

  // continuous ($ link); And flush () foreach ($ link- & gt; getTranslations () as $ linkTranslation) {$ linkTranslation-> Settranslate ($ link); $ Em- & gt; Continues ($ linkTranslation); } $ Em- & gt; Flush ();  

Of course this is not the answer for which I see :)

you have to 'by_reference' = & gt; Add these methods to the false option in the translation field and then your link unit (see)

  public Function addTranslation (LinkTranslation $ t) {$ t- & gt; Settranslateable ($ this); $ This- & gt; GetTranslations () - & gt; ($ T) add; } Public Function Deletion Translation (Link Translation Translation $ T) {$ this- & gt; GetTranslations () - & gt; Remove ($ t); }  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -