Reputation: 831
I'm trying to create a form with translated labels. I'm not using an AbstractType
class, I just want to declare my form in a controller :
$form = $this->createFormBuilder($user)
->add('website', 'url', array(
'required' => false,
'label' => 'profession.website.label'
));
How can I add a translation domain to my form ?
Upvotes: 2
Views: 253
Reputation: 9362
I believe you pass it as an array to the 2rd argument for createFormBuilder
$form = $this->createFormBuilder($user, [
'translation_domain' => 'comment'
])->add('website', 'url', [
'required' => false,
'label' => 'profession.website.label'
]);
First argument is the data for the form, the second is the options. http://api.symfony.com/2.0/Symfony/Bundle/FrameworkBundle/Controller/Controller.html#method_createFormBuilder
Upvotes: 4