Hello everyone!
I need your help, I am using the multimodelform extension to allow user pick many items (models) with their properties and then save them in models.
The problem I am having now is that I show a combobox and everything is fine, but dont know how to make a combobox with categories (as OPTGROUPS)
in the widget properties:
'formConfig' => $examen->getMultiModelForm(), //the form configuration array
then
public function getMultiModelForm()
{
$listaExamenes = Examen::getListExamen();
return array(
'elements'=>array(
'examen_id'=>array(
'type'=>'dropdownlist',
'items'=>$listaExamenes,
'prompt'=>'Seleccione un exámen',
),
'cantidad'=>array(
'type'=>'number',
'min'=>1,
'max'=>10,
// 'value'=>0,
),
));
}
and
public static function getListExamen() {
$examenes = Examen::model()->findAll(array('order'=>'nombre', 'condition'=>'t.activo = 1'));
return CHtml::listData($examenes,'id','nombre');
}
I have two db tables
‘examen’ which contains all clickable items, and it has a foreign key ‘examen_tipo_id’ which refers to the table that categorize the items.
example:
table examen (id, name, foreign_key)
1 - item1 - 1
2 - item2 - 1
3 - item3 - 2
table examen_tipo (id, name)
1 - cat1
2 - cat2
Then, I want the combobox like
cat1
-
item1
-
item2
cat2
- item3
I have seen examples in a form, but how to do it in a formbuilder mode?
thanks in advanced!