title: Saving a checkbox value in Yii
body: <p>I can't figure out how to properly save checkbox values in Yii. I have a MySQL column, <code>active</code>, defined as a <code>tinyint</code>. I have the following form creation code, which correctly shows the checkbox as checked if the value is 1 and unchecked if 0:</p>
  
  <pre><code>    &lt;?php echo $form-&gt;labelEx($model,'active'); ?&gt;
      &lt;?php echo $form-&gt;checkBox($model,'active'); ?&gt;
      &lt;?php echo $form-&gt;error($model,'active'); ?&gt;
  </code></pre>
  
  <p>And the code to save the form correctly changes other, text-based values:</p>
  
  <pre><code>public function actionUpdate($id)
  {
      $model=$this-&gt;loadModel($id);
  
      if(isset($_POST['Thing']))
      {
          $model-&gt;attributes=$_POST['Thing'];
          if($model-&gt;save())
              $this-&gt;redirect(array('thing/index'));
      }
  
      $this-&gt;render('update',array(
          'model'=&gt;$model,
      ));
  }
  </code></pre>
  
  <p>The value of <code>active</code> is not saved. Where am I going wrong?</p>