Yii Framework Forum: NULL field after model->save() - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

NULL field after model->save() After upgrade Yii from 1.0 to 1.1 Rate Topic: -----

#1 User is offline   netbur 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 03-June 09

Posted 11 January 2010 - 06:19 AM

Hi :

We've updated our project to new version of yii 1.1

On comment insert everything works fine, except the content of the comment is NULL, before the update this action works fine.

This is my funtion

protected function newComentario($articulo)
{
$comentario=new comentario;
if(isset($_POST['comentario']))
{
$comentario->attributes=$_POST['comentario'];
$comentario->articulo_id=$articulo->id;
$comentario->created_at=date('Y-m-d h:i:s');

}
if(isset($_POST['submitComment']) && $comentario->save())
{
Yii::app()->user->setFlash('commentSubmitted','Thank you for your comment. Your comment will be posted once it is approved.');
$this->refresh();

}
return $comentario;


And the form:


<fieldset id="comentario_form">
<legend align= "center"><?php echo CHtml::image(Yii::app()->baseUrl.'/images/escribir_comentario.jpg'); ?></legend>

<div class="yiiForm">
<?php echo CHtml::beginForm(); ?>

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

<div class="simple">
<strong><?php echo CHtml::activeLabel($comentario,'autor'); ?></strong>
<?php echo CHtml::activeTextField($comentario,'autor'); ?>
</div>
<div class="simple">
<strong><?php echo CHtml::activeLabel($comentario,'texto'); ?></strong>
<?php echo CHtml::activeTextArea($comentario,'texto',array('rows'=>5, 'cols'=>35)); ?>
</div>

<?php if(extension_loaded('gd')): ?>
<div class="simple" >
<strong><?php echo CHtml::activeLabel($comentario,'verifyCode'); ?></strong>
<?php echo CHtml::activeTextField($comentario,'verifyCode',array('size'=>10,'maxlength'=>10)); ?>
</div>
<?php $this->widget('CCaptcha'); ?>
<?php endif; ?>

<div class="action">
<?php echo CHtml::submitButton($update ? 'Save' : 'Enviar', array('name'=>'submitComment')); ?>
</div>

<?php echo CHtml::endForm(); ?>
</div><!-- form -->

</fieldset>


Thanks
0

#2 User is offline   Sander 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 169
  • Joined: 03-November 09
  • Location:Amsterdam, Netherlands

Posted 12 January 2010 - 03:39 AM

Read up on safe attributes, the way they work has changed from 1.0 to 1.1 and you probably don't have a rule set for your comment property.

Also, please format your code with [php] tags, makes it so much easier to read. Thanks.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users