Add a class to the entry and label when you create selection boxes in CakePHP

advertisements

So Here is how the select boxes are being created:

    echo $this->Form->select('weekdays', array(
         '1'=>__('Manday'),
         '2'=>__('Tuesday'),
         '3'=>__('Wednesday'),
         '4'=>__('Thursday'),
         '5'=>__('Friday'),
         '6'=>__('Satruday'),
         '7'=>__('Sunday')),
       array('multiple'=>'checkbox', 'class'=>'checkbox2'));

which outputs 7 checbox with the following HTML markup:

<div class="checkbox2">
<input type="checkbox" name="data[Event][weekdays][]" value="1" id="EventWeekdays1" />
<label for="EventWeekdays1">Monday</label>
</div>

But the expected output that is needed is this:

<div class="checkbox2">
<input type="checkbox"
       name="data[Event][EventWeekdays1]"
       id="EventWeekdays1" class="css-checkbox" value="1" />
<label for="EventWeekdays1" class="css-label">Mandag</label>
</div>

I have been through documentation but cannot seem to find an option to add clases to both input and label attributes when using Form->select

Any help or guidance is much appreciated.


Using just FormHelper-approved things:

$options = array(
     '1'=>__('Manday'),
     '2'=>__('Tuesday'),
     '3'=>__('Wednesday'),
     '4'=>__('Thursday'),
     '5'=>__('Friday'),
     '6'=>__('Satruday'),
     '7'=>__('Sunday'));

$this->Form->input('weekdays', array(
                       'type' => 'select',
                       'div' => array('class'=>'checkbox2'),
                       'multiple'=>'checkbox',
                       'class'=>'css-checkbox',
                       'options' => $options,
                       'label' => array('class'=>'css-label')));

Docs here