SOLVED: ActiveRecord attributes bug

setting attributes does not work, but setting content like this does


$newNote->content = $_POST['note']['content'];

is it possible attributes does not work unless it’s count is greater than 1?




<?php if(Yii::app()->user->hasFlash('note')): ?>

  <div class="confirmation">

    <?php echo Yii::app()->user->getFlash('note'); ?>

  </div>

<?php else: ?>

  <div class="form">


    <?php echo CHtml::beginForm(); ?>

    <?php echo CHtml::errorSummary($newNote); ?>


    <div class="simple">

      <?php echo CHtml::activeLabel($newNote,'content'); ?>

      <?php echo CHtml::activeTextArea($newNote,'content'); ?>

    </div>


    <div class="action">

      <?php echo CHtml::submitButton('Add Note'); ?>

    </div>


    <?php echo CHtml::endForm(); ?>

  </div>

<?php endif; ?>





	  $newNote = new Note();

	  if (isset($_POST['note']))

	  {

	    $newNote->attributes = $_POST['note'];

	    //$newNote->content = $_POST['note']['content'];


	    $newNote->userId = Yii::app()->user->actualId;

	    $newNote->inspectionId = $inspection->id;


	    if ($newNote->save())

	    {

	      $this->refresh();

	    }

	  }

operating system = Windows 7

Web server = Apache

browser type = Chrome

Yii version or SVN revision = 1.1.0

Is "content" a safe attribute? (declared in rules())?

rules is commented out, there are no restrictions for this particular model.

Please read the guide http://www.yiiframework.com/doc/guide/form.model (Safe Attributes in 1.1)

There is BC-breaking change in 1.1 regarding batch attribute assignment

Very good! Thanks qiang.