Great, this worked perfect. I ended up using something like this:
for($i=1;$i<=5; $i++) {
$fieldName = 'field_'.$i;
if ($TypeModel->$fieldName == 1) //check model for 1 or 0
$TypeModel->type[$i] = $i; //using $i instead of 1 since we need checkbox value, but model only stores 0 or 1
else $TypeModel->type[$i] = 0;
Again, really appreciate your help and instruction!
I tested it but I can’t get the options take the whole width of the widget. They are left-aligned (about on the 100 first px I think) even if I increase the width of the widget.
I assume that the same problem exists when you define the width via ‘width:450px’ instead of span-10?
It seems to me, that there are other style-declarations (like width, or float:right etc.) that affect the checkboxes and make them appear that way…
Do you use Firebug (the add-on for firefox)?
With firebug you could determine what styles exactly are applied to the checkboxes.
Sometime css-styles do behave unexpectedly and if there are more than one css-file, something overrides the other and there is no way to know what happpens without some tool like firebug…
It is really difficult to say something without seeing the code, but I have the suspicion that somewhere in your css files there is a style declaration for the ‘label’ element that sets a fixed width for it and makes the text within right aligend, i.e. something like this:
label {
width:100px;
text-align:right;
}
This is often done to style form elements, where a label is followed by a text-field for example, to produce forms like here: http://jeffhowden.com/code/css/forms/
Note that the labels are right aligned and how they are styled further below:
I want to display it like a multiple checkbox list but without the user to click on the scroller => always display the entire list (and abusing : is it possible in that case that the checkboxes take the entire height before the next component? - css? my weakness)
I’m afraid I don’t know an easy way to tweak EchMultiSelect like you want… apart from trial-error…
I have a few ideas, but I don’t know if they would work properly:
With the ‘autoOpen’ set to true, you can make the checkboxes appear on page load
If you comment out the ‘close’ function in the js-file (jquery.multiselect.js), the displayed checkbox container then would never close.
with the ‘height’ option you could fix the height (for example 500px;)
To make sure the the checkbox container is not positioned over other elements, you could put the EchMultiSelect widget into a div with the style="height:550x; display:block;" (adjust height to the height of the container)
I am always getting only one values even though i have selected multiple of data.If i use dropDownAttribute instead of name ,then it works but if I want to update it doesn’t work with dropDownAttribute but shows the value while using name. So i want to use name instead of dropDownAttribute in EchMultiselect,but the problem is it doesn’t save the multiple selected value
But generally speaking, to use the ‘name’ attribute and save the selected values, your view fiel should look like (I use the example from the extension page):
This will produce a dropdown list of the six colors.
‘red’ and ‘black’ will be preselected (because declared in ‘value’ attribute).
In your controller actionUpdate, $_POST[‘colors’] will be an array that contains the keys of the selected colors. If for example yellow, green and blue are selected before update, then $_POST[‘colors’] will be:
$_POST['colors'] = array(1, 4, 5);
Note that you have to save these selected values manually where you want to have them saved. That will not happen automatically!
In this example I could have a table ‘obj_color’, in which I want to store the selected colors for an object with the id $obj_id. I would have to save these values in the Update action like so:
foreach($_POST['colors'] as $color_id) {
$ocolor = new ObjColor;
$ocolor->obj_id = $obj_id;
$ocolor->color_id = $color_id;
$ocolor->save();
}
In any case, you will have to use a foreach-loop in your controller to loop through the selected values and process/save them.