How to save the ID of the selected hobbies in database in yii 1.13
<p><a href="https://i.stack.imgur.com/q2Eqt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q2Eqt.png" alt="My Registration Page"></a>I need to store the id of the selected hobbies from my check box in database. First, in my Hobbies table, i view all the hobby names and display it in check box. Now, whichever the hobbies selected, it stores the id of the hobbies in another table.</p>

<p>This is my code in <strong>views/sample/register.php</strong></p>

<pre><code>&lt;div class="row"&gt;
    &lt;?php echo $form-&gt;labelEx($model,'hobby');
    $opts = CHtml::listData(Hobbies::model()-&gt;findAll(),'hobby_id','hobby_name');
    echo $form-&gt;checkBoxList($model,'hobby',$opts, array('labelOptions'=&gt;array('style'=&gt;'display:inline'),'separator'=&gt;'  '));
    echo $form-&gt;error($model,'hobby'); ?&gt;
&lt;/div&gt;
</code></pre>

<p>And this is my code in <strong>controllers/SampleController.php</strong></p>

<pre><code>if($model-&gt;validate())
        {
            $model-&gt;hobby = implode(",",$model-&gt;hobby);
            if($model-&gt;save())
            {
               $this-&gt;redirect(array('site/login'));
            }
            return;
        }
</code></pre>

<p>But it displays an error as <strong><em>PHP warning mb_strlen() expects parameter 1 to be string, array given</em></strong>. Please anybody help.</p>