Error In Client Side With Values From Ckeditor

Hi,

In my view i have a field which is a ckeditor(product description). I am using client side validation. But when i submit the form validation error appear before it submitted.I have attached a screen shot of the screen.And the relevant code.

This is view part.




<?php

                        $form = $this->beginWidget('CActiveForm', array(

                            'id' => 'product-form',

                            'enableAjaxValidation' => true,                         

                            'htmlOptions' => array('enctype' => 'multipart/form-data', 'data-ajax' => 'false'),

                            'clientOptions'=>array(

                                'validateOnSubmit'=>true,

                            ),

                        ));

                        ?>


                        <p class="note">Fields with <span class="required">*</span> are required.</p>


                        <?php echo $form->errorSummary($model); ?>

                        <div id="general">

                            <div class="row">

                                <?php echo $form->labelEx($model, 'name'); ?>

                                <?php echo $form->textField($model, 'name', array('size' => 60, 'maxlength' => 200)); ?>

                                <?php echo $form->error($model, 'name'); ?>

                            </div>


                            <div class="row">

                                <?php echo $form->labelEx($model, 'description'); ?>

                                <?php echo $form->textArea($model, 'description', array('id' => 'editor1')); ?>

                                <?php echo $form->error($model, 'description'); ?>

                            </div>


                            <div class="row">

                                <?php echo $form->labelEx($model, 'status'); ?>

                                <?php echo $form->dropDownList($model, 'status', array(1 => 'Enabled', 0 => 'Disabled')); ?>

                                <?php echo $form->error($model, 'status'); ?>

                            </div>

                        </div>



This is controller




public function actionCreate()

    {

        $_SESSION['KCFINDER']['disabled'] = false; // enables the file browser in the admin

        $_SESSION['KCFINDER']['uploadURL'] = Yii::app()->baseUrl."/uploads/"; // URL for the uploads folder

        $_SESSION['KCFINDER']['uploadDir'] = Yii::app()->basePath."/../uploads/"; // path to the uploads folder


        $model=new Product;


        // Uncomment the following line if AJAX validation is needed

        $this->performAjaxValidation($model);

        

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

        {

            $model->attributes=$_POST['Product'];

            $model->date_added=date("Y-m-d H:i:s");

            $model->date_updated=date("Y-m-d H:i:s");

            $model->tenant_id=1;



And the model




/**

	 * @return array validation rules for model attributes.

	 */

	public function rules()

	{

		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('name, description, tenant_id', 'required'),

			array('status, tenant_id', 'numerical', 'integerOnly'=>true),

			array('name', 'length', 'max'=>200),

			array('date_added, date_updated, product_image', 'safe'),

            //array('product_image', 'file', 'types'=>'jpg, gif, png'),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('name, description, status', 'safe', 'on'=>'search'),

		);

	}




 

4708

bug.JPG

I would be much thankful if any one can help me on this.

Hi if you validate product description on form or not? if not just remove the rule function on model


 array('name,tenant_id', 'required'),

Hi,

Thanks for the reply. I need to validate product description. But the issue is. Even though i entered a value(please check the image) it shows the given error and then submits. The problem is why error showing when there is a value.

i think you want to write a $model->save() so just write a $model->save(false)

or just remove the line on action

$this->performAjaxValidation($model);