drskullster drskullster - 6 months ago 25
PHP Question

Set a translation domain on a form created without a class

I'm trying to create a form with translated labels. I'm not using an

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 ?


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