how to style a symfony2 form button

Matt Welander

How do I simply add a css class or inline style to a button like this? Is there something you can put in that array() where I got label?

private function createDeleteForm($id)
{
    return $this->createFormBuilder()
        ->setAction($this->generateUrl('video_delete', array('id' => $id)))
        ->setMethod('DELETE')
        ->add('submit', 'submit', array('label' => 'Radera denna video'))
        ->getForm()
    ;
}

I tried the aged old trick of looking at the elements id to see if I could sort of hack it by putting #ItsId in my css file, but no it doesn't have an id. It renders like this:

<form method="post" action="/site/web/app_dev.php/Media/video/1/delete">
    <input type="hidden" name="_method" value="DELETE">

        <div id="form">
            <div>
                <button type="submit" id="form_submit" name="form[submit]">
                    Radera denna video
                </button>
            </div>

            <input type="hidden" id="form__token" name="form[_token]" value="2c2889b6744aade419618485e1b3ce0c9c341a42">

        </div>
</form>
Derick F
->add('submit', 'submit', array(
    'label' => 'Radera denna video', 
    'attr' => array('class' => 'class-you-wish-to-add')
));

This is a duplicate of: How to set a class attribute to a Symfony2 form input

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails: How to style form submit button

From Dev

Symfony2 remove default Form fields style class

From Dev

How to click on a button in PHPUnit (Symfony2)

From Dev

How to submit form ajax in symfony2?

From Dev

How to set form name in Symfony2?

From Dev

How to name a form in symfony2?

From Dev

How to specify Symfony2 Bootstrap checkbox inline style?

From Dev

How can you style Django's file picker form button?

From Dev

Symfony2: How to use constraints on custom compound form type?

From Dev

How to check whether field exists in symfony2 form?

From Dev

How to create a form with multiple rows of one entity in Symfony2

From Dev

symfony2: how to make a form field not required on update

From Dev

How to valid a form which has collections in Symfony2?

From Dev

How define textarea content on form edit (Symfony2/TWIG)

From Dev

How do I pass a value to Form Builder in Symfony2?

From Dev

Symfony2 : How to remove form field in listener, after submit

From Dev

How to access form elements in controller symfony2

From Dev

How to add a <hr> in Symfony2 form builder?

From Dev

Symfony2: how to validate UploadedFile without form?

From Dev

Symfony2 - How to validate autocomplete entity form type?

From Dev

How to assign a validation group on specific form element in Symfony2

From Dev

Symfony2 How to create one form for many the same entities?

From Dev

How to tests form events and eventListeners in symfony2 functional tests?

From Dev

How to create a custom Symfony2 Twig form template block

From Dev

How should I embed a paragraph in a Symfony2 form?

From Dev

How to use an array as choices for "choice" in form builder symfony2

From Dev

Symfony2 Forms - How to use parametrized constructors in form builders

From Dev

How to get all form errors symfony2

From Dev

How to create a complex form in Symfony2 with Doctrine

Related Related

  1. 1

    Rails: How to style form submit button

  2. 2

    Symfony2 remove default Form fields style class

  3. 3

    How to click on a button in PHPUnit (Symfony2)

  4. 4

    How to submit form ajax in symfony2?

  5. 5

    How to set form name in Symfony2?

  6. 6

    How to name a form in symfony2?

  7. 7

    How to specify Symfony2 Bootstrap checkbox inline style?

  8. 8

    How can you style Django's file picker form button?

  9. 9

    Symfony2: How to use constraints on custom compound form type?

  10. 10

    How to check whether field exists in symfony2 form?

  11. 11

    How to create a form with multiple rows of one entity in Symfony2

  12. 12

    symfony2: how to make a form field not required on update

  13. 13

    How to valid a form which has collections in Symfony2?

  14. 14

    How define textarea content on form edit (Symfony2/TWIG)

  15. 15

    How do I pass a value to Form Builder in Symfony2?

  16. 16

    Symfony2 : How to remove form field in listener, after submit

  17. 17

    How to access form elements in controller symfony2

  18. 18

    How to add a <hr> in Symfony2 form builder?

  19. 19

    Symfony2: how to validate UploadedFile without form?

  20. 20

    Symfony2 - How to validate autocomplete entity form type?

  21. 21

    How to assign a validation group on specific form element in Symfony2

  22. 22

    Symfony2 How to create one form for many the same entities?

  23. 23

    How to tests form events and eventListeners in symfony2 functional tests?

  24. 24

    How to create a custom Symfony2 Twig form template block

  25. 25

    How should I embed a paragraph in a Symfony2 form?

  26. 26

    How to use an array as choices for "choice" in form builder symfony2

  27. 27

    Symfony2 Forms - How to use parametrized constructors in form builders

  28. 28

    How to get all form errors symfony2

  29. 29

    How to create a complex form in Symfony2 with Doctrine

HotTag

Archive