by using Lithium form helper we can insert a select
tag that a single item can be selected.
sample:
echo $this->form->field('myfield', array(
'type' => 'select',
'list' => array(
'id1' => 'value1',
'id2' => 'value2',
),
)
);
Now if you want to use Select2
jQuery plugin with multiple
option, field
method in form helper
tries to retrieve submitted value in string.
even when multiple
option is set!
non-working sample:
echo $this->form->field('myfield', array(
'type' => 'select',
'list' => array(
'id1' => 'value1',
'id2' => 'value2',
),
'multiple' => true,
)
);
field
method won't accept array value in submitted forms.
so try select
method in Form Helper with a multiple
option.
sample code:
echo $this->form->select('myfield',
array(
'id1' => 'value1',
'id2' => 'value2',
),
array(
'multiple' => true,
)
);