Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Multiselect Values How To Save In Database In Controller

$
0
0
i have using dropdown multiselect values save in db how to save ,i tryed in my controller side but its show error is "Array to string conversion" how to solve and my code for controller and view part dropdown

in my form

<div class="row">
<b style=" padding-right: 60px;">Targeted_muscles <span class="required">* </span> </b><?php echo $form->dropdownList($model,'targeted_muscles', CHtml::listData(Muscles::model()->findAll(array('order' => 'muscles_name')), 'id', 'muscles_name'), array('empty'=>'Select ' ,'multiple'=>'multiple',),array('class'=>'select','asc'=>'muscles_name',
) )


?>

<?php echo $form->error($model,'targeted_muscles'); ?>
</div>




in my controller
if(isset($_POST['ExMusclesDetails']))
{
$model->attributes=$_POST['ExMusclesDetails'];

foreach($_POST['ExMusclesDetails']['targeted_muscles'] as $value){

// OR 1,2

$ID_STRING= explode(",",$value);

$model->targeted_muscles=$value;
$model->save();

}

please help what is wrong in my code

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>