In most of the cases this code snippet will help to generate a form via gii:

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'form-id',
    'enableAjaxValidation'=>true,
    'clientOptions' => array(
        'validateOnSubmit'=>true,
        'validateOnChange'=>true,
        'validateOnType'=>false,
    ),
)); ?>

If you create your own form, and trying to do this… better create CRUD with gii, and see how it is done there!

You need to echo the validation results if this is an Ajax request! By using:

echo CActiveForm::validate($model);

Posted in: Yii

Related FAQ's

Marius Ion ANGEL HOT SOFT LLC (800) 316-7677