Apply class to Symfony2 Form Label

I’ve got it… <?php echo $view[‘form’]->label($form[‘first_name’], ‘First Name’, array( ‘label_attr’ => array(‘class’ => ‘control-label’), )) ?> Apparently “attr” is “label_attr” for labels fields. P.S. Corresponding twig code {{ form_label(form.first_name, ‘First Name’, { ‘label_attr’: {‘class’: ‘control-label’} }) }}

How to pass parameter to FormType constructor from controller

Thanks for your time! i resolved this myself: I removed parameter from NewsType constructor and added data to postedBy form field using $options array, and passed data to $options array from controller, please check following: NewsType public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add(‘postedBy’, HiddenType::class, array( ‘data’ => $options[‘postedBy’] ) ) ; } // … Read more

Symfony2 Setting a default choice field selection

You can define the default value from the ‘data’ attribute. This is part of the Abstract “field” type (http://symfony.com/doc/2.0/reference/forms/types/field.html) $form = $this->createFormBuilder() ->add(‘status’, ‘choice’, array( ‘choices’ => array( 0 => ‘Published’, 1 => ‘Draft’ ), ‘data’ => 1 )) ->getForm(); In this example, ‘Draft’ would be set as the default selected value.

Difference between ObjectManager and EntityManager in Symfony2?

ObjectManager is an interface and EntityManager is its ORM implementation. It’s not the only implementation; for example, DocumentManager from MongoDB ODM implements it as well. ObjectManager provides only the common subset of all its implementations. If you want your form type to work with any ObjectManager implementation, then use it. This way you could switch … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)