title: Yii receiving data from checkboxlist
body: <p>I have some project in Yii. First it was a form with two text fields: Name and Subject (subject is list of subjects separated by comma). Now I need to replace subject text field with list of checkboxes, which will add the same string separated by comma.</p>
  
  <pre><code>&lt;!--&lt;?php echo $form-&gt;labelEx($model,'Subjects'); ?&gt;
  &lt;?php echo $form-&gt;textField($model,'Subjects',array('size'=&gt;60,'maxlength'=&gt;255)); ?&gt;
  &lt;?php echo $form-&gt;error($model,'Subjects'); ?&gt;--&gt;
  &lt;?php echo $form-&gt;labelEx($model,'Subjects'); ?&gt;
  &lt;?php echo $form-&gt;checkBoxList($model,'Subjects',$this-&gt;listOfSubjects()); ?&gt;
  &lt;?php echo $form-&gt;error($model,'Subjects'); ?&gt;
  </code></pre>
  
  <p>List of subjects is a controller method that returns array required for checkboxlist in Yii, something like: </p>
  
  <pre><code>array(
  '1'=&gt;'Something',
  '2'=&gt;'Anotherthing'
  );
  </code></pre>
  
  <p>Also here is code of my action create. It's rather standart:</p>
  
  <pre><code>public function actionCreate()
  {
      $model=new CrdTeachers;
      if(isset($_POST['CrdTeachers']))
      {
          $model-&gt;attributes=$_POST['CrdTeachers'];
          if($model-&gt;save())
              $this-&gt;redirect(array('view','id'=&gt;$model-&gt;Teacher_ID));        
      }
      $this-&gt;render('create',array(
          'model'=&gt;$model,
      ));
  }
  </code></pre>
  
  <p>This code worked fine when there was just two text fields. Now when I'm using create action it says that mistake:</p>
  
  <pre><code>mb_strlen() expects parameter 1 to be string, array given
  </code></pre>
  
  <p>I can't find where can I process it's data to make it string. Any experts of Yii here? What should I look for?<br>
  <strong>UPDATE:</strong>
  Here is CRDTeachers model class</p>
  
  <pre><code>class CrdTeachers extends CActiveRecord
  {
      /**
       * Returns the static model of the specified AR class.
       * @param string $className active record class name.
       * @return CrdTeachers the static model class
       */
      public static function model($className=__CLASS__)
      {
          return parent::model($className);
      }
  
      /**
       * @return string the associated database table name
       */
      public function tableName()
      {
          return 'crd_teachers';
      }
  
      /**
       * @return array validation rules for model attributes.
       */
      public function rules()
      {
          // NOTE: you should only define rules for those attributes that
          // will receive user inputs.
          return array(
              array('Name, Subjects', 'required'),
              array('Name, Subjects', 'length', 'max'=&gt;255),
              // The following rule is used by search().
              // Please remove those attributes that should not be searched.
              array('Teacher_ID, Name, Subjects', 'safe', 'on'=&gt;'search'),
          );
      }
  
      /**
       * @return array relational rules.
       */
      public function relations()
      {
          // NOTE: you may need to adjust the relation name and the related
          // class name for the relations automatically generated below.
          return array(
              //'rSubjects'=&gt;array(self::HAS_MANY, 'CrdSubjects', 'Subject_ID'),
              //'categories'=&gt;array(self::MANY_MANY, 'CrdTeachers', '{{CrdSubjects}}(Subject_ID, Subject_Name)'),
          );
      }
  
      public function behaviors()
      {
          return array(
              'DMultiplyListBehavior'=&gt;array(
                   'class'=&gt;'DMultiplyListBehavior',
                   'attribute'=&gt;'categoriesArray',
                   'relation'=&gt;'categories',
                   'relationPk'=&gt;'id',
              ),
          );
      }
  
      protected function afterSave()
      {
          //$this-&gt;refreshCategories();
          parent::afterSave();
      }
  
      protected function refreshCategories()
      {
          $categories = $this-&gt;categoriesArray;
  
          CrdTeachers::model()-&gt;deleteAllByAttributes(array('Subject_ID'=&gt;$this-&gt;id));
  
          if (is_array($categories))
          {
              foreach ($categories as $id)
              {
                  if (Category::model()-&gt;exists('id=:id', array(':id'=&gt;$id)))
                  {
                      $postCat = new CrdTeachers();
                      $postCat-&gt;post_id = $this-&gt;id;
                      $postCat-&gt;category_id = $id;
                      $postCat-&gt;save();
                  }
              }
          }
      }   
  
      /**
       * @return array customized attribute labels (name=&gt;label)
       */
      public function attributeLabels()
      {
          return array(
              'Teacher_ID' =&gt; 'Teacher',
              'Name' =&gt; 'Name',
              'Subjects' =&gt; 'Subjects',
          );
      }
  
      /**
       * Retrieves a list of models based on the current search/filter conditions.
       * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
       */
      public function search()
      {
          // Warning: Please modify the following code to remove attributes that
          // should not be searched.
  
          $criteria=new CDbCriteria;
  
          $criteria-&gt;compare('Teacher_ID',$this-&gt;Teacher_ID);
          $criteria-&gt;compare('Name',$this-&gt;Name,true);
          $criteria-&gt;compare('Subjects',$this-&gt;Subjects,true);
  
          return new CActiveDataProvider($this, array(
              'criteria'=&gt;$criteria,
          ));
      }
  
      /*
      * Возвращает список по ID
      */
      public function getParentTypeById($id) {
          $title = $this-&gt;model()-&gt;findByPk($id)-&gt;Name;
          return $title;
      }   
  }
  </code></pre>