Search Results

Search found 1 results on 1 pages for 'ninsuo'.

Page 1/1 | 1 

  • Create a multicolor selectbox on Symfony2

    - by Ninsuo
    I try to create the following field : <select name="test"> <option value="1">a</option> <option value="2">b</option> <option value="3" style="font-weight: bold; color: red;">c</option> <option value="4">d</option> <option value="5">e</option> </select> This creates a 2-color selectbox : But in Symfony2, I do not know how to apply a class to a single option. If in my view I do : {{ form_widget(myForm.test, { 'attr': { 'class': 'red', } }) }} Or if in my form I do : $builder->add('test', 'choice', array( 'required' => true, 'choices' => array('a', 'b', 'c', 'd', 'e'), 'attr' => array('class' => 'red'), )); The attribute is stored into the <select> tag and apply to the whole selectable values. How do I apply a class to an <option> in Symfony2 ?

    Read the article

1