GSTAR
(Omzy83)
December 4, 2009, 3:34pm
1
By default the checkBoxList generates a default formatting, I want it to generate custom formatting as follows:
(for each checkbox:)
<tr>
<td class="label"><label for="index">value</label></td>
<td><input type="checkbox" id="index" /></td>
</tr>
GSTAR
(Omzy83)
December 5, 2009, 11:49pm
2
Can anyone help me with this please?
tri
(tri - Tommy Riboe)
December 6, 2009, 12:08am
3
By default the checkBoxList generates a default formatting, I want it to generate custom formatting as follows:
(for each checkbox:)
<tr>
<td class="label"><label for="index">value</label></td>
<td><input type="checkbox" id="index" /></td>
</tr>
Is this what you want to do? (The generated attributes ar still the same)
echo CHtml::checkBoxList('...','...', array(...),
array('template'=>'<tr><td >{label}</td><td>{input}</td></tr>')
);
/Tommy
GSTAR
(Omzy83)
December 7, 2009, 11:00am
4
Cheers mate, that’s done the job perfectly.
GSTAR
(Omzy83)
December 11, 2009, 2:46pm
5
Anybody know how can I split this checkBoxList and display it in two columns (side by side)? Is there any function in Yii that can do this?
trevor
(Tmdonalds)
December 15, 2009, 1:57pm
6
Did anyone figure out how to display the checkboxlist as two columns?
Thanks
Ricardo
(Piotr Komorek)
December 16, 2009, 11:43am
7
Two columns? You mean something like:
label checkbox
label checkbox
label checkbox
or
label checkbox label checkbox
label checkbox label checkbox
label checkbox label checkbox
?
GSTAR
(Omzy83)
December 16, 2009, 12:11pm
8
Your second example.
I kind of figured out how to do it, I had to use a foreach loop and generate the checkboxes manually. So in other words I was unable to do it using the checkBoxList method. It would have been nice if there was a built in functionality in Yii to acheive this.
trevor
(Tmdonalds)
December 16, 2009, 12:17pm
9
This is the direction I went in as well.
Ricardo
(Piotr Komorek)
December 16, 2009, 2:31pm
10
I think there is no need to achieve that using checkBoxList. CheckBoxList is simply a list. You have template option to modify standard template and that’s it. If you need to achieve something different you build your own solution using single checkbox. In my opinion this is the best way to keep it simple.
Hmm well I like to keep things simple, but I think the Yii CheckBoxList should have something that allows for multiple columns.
Or at least get rid of the last "<br />" after each checkbox so we can float them left.
Pronskiy
(Roman)
August 22, 2011, 11:58am
12
You can get rid of those '<br />'s by specifying ‘separator’ option like this
echo CHtml::checkBoxList('...','...', array(...),
array(
'separator'=>'',
)
);
deboorn
(Daniel Boorn)
August 29, 2011, 6:27pm
13
Example of Pronskiy’s & JamesBarnsley’s advice:
<div class="checkboxgroup">
<?php
echo CHtml::checkBoxList('...','...', array(...),
array(
'separator'=>'',
'template'=>'<div>{input} {label}</div>'
)
);
?>
</div>
<style>
.checkboxgroup{
overflow:auto;
}
.checkboxgroup div{
width:200px;
float:left;
}
</style>
Marian
(Marianbucur17)
March 23, 2012, 6:44pm
14
Hello guys,
I am trying to use checkboxlist, but it inserts all the labels and inputs into a span. How can I remove that span ?
Kind Regards,
Marian