Reputation: 990
i have entity languages
with format
id; name
en; English
pl; Polish
etc...
And I have some Entity translations
, that in one column has an associative array:
{pl: "Some txt in PL", en: "Some txt in EN",...}
Everything is almost perfect, but i don't know how to create an form for editing such a thing :D I tried almost everything.
Translation.orm.yml
:
...
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
length: 255
unique: true
value:
type: array
...
Upvotes: 0
Views: 928
Reputation: 71
For new Entity you must prepare your array in Controller ( before creating form). Something like that:
$value = array('en' => 'here en', 'pl' => 'here pl');
$translation->setValue($value);
$form = $this->createForm(new TranslationType()...
In Your FormType:
$builder->add('value', 'collection', array(
'type' => 'text',
'options' => array(
'required' => true,
),
)
);
That's all.
If you have {{ form_rest(form) }}
in your twig, you'll see two additional fields for translations in your form and it will be work.
Additional information about collection field type is here
Upvotes: 1