i want according plan
- a form have 1 multiselect item
- can cloned using jquery (.clone)
- here must problem because same name of multiselect. (can change using jquery).
- all cloned forms data should inserted database accordingly new rows.
view
echo $this->form->input('book.category.', array( 'class'=>'js_cetegory', 'multiple' => 'multiple', 'type' => 'select', 'label' => 'category', 'options'=>$categories, 'empty'=>'select category' ) );
name change code of multiselect input when clone called
var len = $("#parent").length; $(".top:first").clone().find(".js_cetegory").attr("name", "data[book][cetegory]["+len+"][]").end().appendto('#parent');
my $this->data making array code
[category] => array ( [0] => array ( [0] => 1 [1] => 2 [2] => 7 ) [1] => ) [cetegory] => array ( [1] => array ( [0] => 2 [1] => 7 [2] => 8 ) )
instead of
[category] => array ( [0] => array ( [0] => 1 [1] => 2 [2] => 7 ) [1] => array ( [0] => 2 [1] => 7 [2] => 8 ) )
cake
generating field name
- data[book][cetegory][0]
, data[book][cetegory][1]
...
it should -
echo $this->form->input('book.category.0.', array(
but when cloning names changed data[book][cetegory][1][]
the name of field sholud -
$(".top:first").clone().find(".js_cetegory").attr("name", "data[book][cetegory][][]").end().appendto('#parent');
Comments
Post a Comment