pjravs
(Pravello)
March 17, 2014, 4:19am
61
I have a problem with this widget.
If I close it, it does not show up again. I have to refresh the page to select again. What seems to be the problem?
And also, is there an option that it shows the text that has been selected thanks!
Taegle
(Taegle)
May 27, 2014, 5:24pm
62
This widget seems to be very helpful. However, I’m having an issue that once I open the list , I can’t close it, not by clicking the select nor by the X button. Does anyone knows how to fix it?
I’m using Yii 1.1.14!
epulgaron
(Jokercrazy05544)
June 25, 2014, 2:49pm
63
I have tried to use this extension, but I several problems arise
1-not the dropdown closes when I choose an item
2-close button does not work me
3-when I give "insert" an element over my application throws me the error "field must be a number", the primary keys are integers and auto-increment
any idea?
One possibility is the following:
you define a new attribute/variable in the model file, at the beggining, directly after the class starts:
class Car extends CActiveRecord {
$colors = array();
...
}
The name of the variable should not be equal to a column name. Here, your model/table should not have a column named ‘colors’. You then use this new attribute in the widget:
$this->widget('ext.widgets.EchMultiselect', array(
'model' => $model,
'dropDownAttribute' => 'colors',
'data' => $data,
});
In the controller file, you then have the array
$_POST['Cars']['colors']
that provides the id’s of the clicked/selected colors for further use.
To handle the field_1,…,field_N columns:
You could build an array, like
$data = array('field_1',...,'field_N');
and use it as the data source in the widget above.
Then in the controller you can loop from 1 to N and check for each, if the correspondig box was selected and set the field_X accordingly. Something like:
if( in_array(X,$_POST['Cars']['colors']) ) $model->field_X = 1;
else $model->field_X = 0;
Otherwise, you would have to provide a separate checkbox for each of the field_X columns in your form. And to combine a set of checkboxes into a dropdown of checkboxes, I think we would need a different widget.
Best regards…