I have 1 Category table and second Features table and have association among them is HABTM in cakephp
Now i don't know exactly how to insert values in categories_features table. I used HABTM before but at that time i insert values in this table when one item is created by using "saveAll()" method. but in this case i have seprate page when categories in drop down menu and features in checkbox form.
i tried to create new model categoriesFeature to solve this problem, but when i submit data , data in in this form
Array
(
[CategoriesFeature] => Array
(
[Category_id] => 2
[feature_id] => Array
(
[0] => 1
[1] => 2
)
)
)
so i get error
"Array to string conversion [CORE\Cake\Model\Datasource\DboSource.php, line 1009]"
Column not found: 1054 Unknown column 'Array' in 'field list'
"INSERT INTO `ecomerce`.`categories_features` (`feature_id`) VALUES (Array)"
if i'm using wrong approach kindly guide me.
View code to add data in categories_features table
<?php echo $this->Form->create('CategoriesFeature', array('id' => 'cf'));?>
<fieldset>
<legend>Feature Add Form</legend>
<?php
echo $this->Form->input('Category_id',array(
'data-rel' => 'chosen',
'placeholder' => 'Select Category'
));
$keys= array();
$values =array();
echo "<h2> Select Features for above selected Category </h2>";
echo $this->Form->input('feature_id',
array('label'=>'',
'type'=>'select',
'multiple'=>'checkbox',
'options'=>$features)
);
echo $this->Form->submit();
?>
</fieldset>
table structure
id | category_id | feature_id