Symfony 1.4 doctrine admin generator display i18n form fields
-
11-10-2019 - |
Pergunta
My problem is that iam using admin generator for model with some extra virtual attributes which i need to have in generator.yml definitions:
config:
form:
display: [name, design_by, description, _images, add_image, _videos, add_video]
But the "description" attribute is in i18n mode of doctrine model s it does'nt exists in core model object anymore - moved into i18n model. So iam getting logical error 'Widget "description" does not exist'.
I tryed somthing like:
config:
form:
display: [description_i18n]
but did'nt found solution.
When i cut the form display definition into default, form starts working, but it miss my extra fields _images, add_image, _videos, add_video, so i need to have the definition there.
Google doesnt helped too...
Does anybody know how to define i18n widgets into generator.yml? THX!
Solução
I had the same problem.
Diving into the code, I saw that the i18n widgets are grouped into arrays where key are the culture name.
So I tried to set them into my generator.yml:
form:
display:
'Name / Description (with translations)': [en, es, fr, it]
And succes!!!
Outras dicas
I have done this before and I am not sure if this is the answer you are looking for but in order for Symfony to display i18n fields in the admin generator you need to add a line to each Form class in your project/lib folder.
For instance if you have a Form class in: <myproject>/lib/form/doctrine/MyForm.class.php
Add this to the configure method like so:
public function configure()
{
parent::configure();
// Add this line.
$this->embedI18n(array('en', 'de'));
...
}
Change en and de to the languages you have set up. You need to do this for every form object you have.