Igor Martins
Igor Martins

Reputation: 2047

Styling a FormHelper multiselect checkbox

I had this multiple checkbox:

<?php echo $this->Form->input('Power', array('type'=>'select', 'multiple' => 'checkbox', 'options' => $poderes, 'label' => false)); ?>

Thats generate this HTML:

<div class="input select"><input type="hidden" name="data[Power][Power]" value="" id="PowerPower"/>

<div class="checkbox"><input type="checkbox" name="data[Power][Power][]" value="1" id="PowerPower1" /><label for="PowerPower1">Negociacao</label></div>
<div class="checkbox"><input type="checkbox" name="data[Power][Power][]" value="2" id="PowerPower2" /><label for="PowerPower2">Comerciais</label></div>
<div class="checkbox"><input type="checkbox" name="data[Power][Power][]" value="3" id="PowerPower3" /><label for="PowerPower3">Compras</label></div>
</div>

I want to put a titlein the <div class="checkbox"> and change the class. I tried many ways and is not working.

How i do this?

Upvotes: 0

Views: 1104

Answers (1)

Dave
Dave

Reputation: 29141

TLDR:

Write manually with PHP foreach()

Explanation:

Remember, CakePHP is just PHP, so look at the field names / ids...etc it auto-generates when you do a $this->Form->input(), and just build a foreach() loop that writes out your checkboxes in whatever manner you want. Voila!

CakePHP is awesome for so many things, but every once in awhile you need enough customization that you just need to fall back to good ole' PHP instead.

Upvotes: 1

Related Questions