I have this form class, in my Symfony 2 project. Everything works fine, but I don't know where to set up form tag attributes.
namespace Forms\FormsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RegistrationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username', 'email', array(
'label' => 'Enter Username',
'attr' => array(
'class' => 'form-control',
'placeholder' => 'Username',
'data-trigger' => 'change',
'data-required' => 'true',
'data-type' => 'email',
)
))
->add('password', 'password', array(
'label' => 'Enter Password',
'attr' => array(
'class' => 'form-control',
'placeholder' => 'Password',
'data-trigger' => 'change',
'data-required' => 'true',
'data-type' => 'password'
)
))
->add('send', 'submit', array(
'attr' => array(
'class' => 'btn btn-primary',
'placeholder' => 'Send'
)
));
}
public function getName()
{
return 'registration';
}
}
Does anyone know if, it's possible to set attributes of form here? E.g. class="something" data-something="true"
Thank you very much for any advice