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
Page 1 of 1
NULL field after model->save() After upgrade Yii from 1.0 to 1.1
#2
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.
Also, please format your code with [php] tags, makes it so much easier to read. Thanks.
Share this topic:
Page 1 of 1

Help














