Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yii ajax validation errors show up

I have the following form:

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
            'id'=>'new-agenda-entry',
            'enableAjaxValidation'=>true,
            'action'=>'')); ?>
        <div class="four columns">
            <div class="right top5 sufix10">
                <?php echo $form->labelEx($model,'eventTime'); ?>
                <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                'name'=>'UserAgenda[eventTime]',
                'model'=>$model,
                'options'=>array(
                    'dateFormat'=>'yy-mm-dd',
                    'minDate'=>'new Date()',
                ) // jquery plugin options
            ));?>
            <?php echo $form->error($model, 'eventTime'); ?>
            </div>
            <div class="right top5 sufix10">
                <?php echo CHtml::dropdownList('eventTime_hour', false, $this->getHourArray()); ?>
                <?php echo CHtml::dropdownList('eventTime_min', false, array('00'=>'00', '30'=>'30')); ?>
            </div>
        <?php echo $form->labelEx($model,'note'); ?>
        <?php echo $form->textField($model, 'note');?>
        <?php echo $form->error($model, 'note'); ?>

The model is successfully validated on the server as I can see the response in Firebug:

{"UserAgenda_eventTime":["Event time cannot be blank."],"UserAgenda_note":["Note cannot be blank."]}

The message seems fine, so does the html but the hidden inputs generated by yii remain hidden and empty.

like image 918
Samson Avatar asked Nov 13 '22 14:11

Samson


1 Answers

in the action maybe (create or update) you have to uncomment // $this->performAjaxValidation($model); like this you have an ajax validation, if the problem persist I think posting it to yiibootstrap discussion in yii forums i better, I see that you use yiibootstrap, try it with default yii form widget.

like image 190
Cherif BOUCHELAGHEM Avatar answered Nov 15 '22 11:11

Cherif BOUCHELAGHEM