I
I
Ivan Trofimov2014-02-27 22:49:40
Yii
Ivan Trofimov, 2014-02-27 22:49:40

Yii CActiveForm: Why doesn't clientValidation work with CHtml::ajaxSubmitButton?

This is how I create the form:

$checkOrderForm = $this->beginWidget('CActiveForm', array(
    'id' => 'check-order-form',
    'stateful' => true,
    'enableClientValidation' => true,
    'clientOptions' => array(
        'hideErrorMessage' => TRUE,
        'validateOnSubmit' => TRUE,
        'validateOnChange' => FALSE,
        'validateOnType' => TRUE,
        'errorCssClass' => 'has-error',
    ),
));

When I use
CHtml::submitButton('Проверить'), array(
    'class' => 'btn btn-red text-bold',
));

then everything is validated and if the field is not filled correctly, then the data is not sent, the fields are highlighted.
And when I use CHtml::ajaxSubmitButton, the form is validated on change, but the data is always sent regardless of the validation result (submit is not prohibited).
CHtml::ajaxSubmitButton( 'Проверить', '', array('update' => '#checkOrderResult') );

What could be the reason?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question