Hi, I’m using yii-1.1.7.r3135. I have a form like this:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id'=>'recovery-form',
'enableClientValidation'=>true,
'focus'=>array($model, 'username'),
'errorMessageCssClass'=>'clsErrorMessage',
'htmlOptions'=>array('autocomplete'=>'off'),
'clientOptions'=>array(
'validateOnSubmit'=>true,
'errorCssClass'=>'clsError',
'successCssClass'=>'clsSuccess',
'validatingCssClass'=>'clsValidating',
),
));
?>
And then I have these two buttons:
<?php
echo CHtml::submitButton(Yii::t('Yii', 'Send'), array('name'=>'ok', 'class'=>'clsPrimaryButton'));
echo CHtml::submitButton(Yii::t('Yii', 'Cancel'), array('name'=>'cancel', 'class'=>'clsSecondaryButton'));
?>
How can I disable client side validation when the Cancel button is pressed? The idea is to redirect to another page when this button is pressed, which I do in the action with this code:
if (isset($_POST['cancel'])) {
$this->controller->redirect(array('login/'));
}
But since I also need client side-validation, the form is never submitted when Cancel is pressed. Of course this simple reditect could be done with a link, but if the cancelation involves other logic (deleting something in session or user state, for instance) then a link would not work.
Note1: in prado this was done with CausesValidation="false" for the button.
Note2: due to graphic design and management issues, I would prefer not to be forced to use a simple CHtml::link for the "cancel".
Thanks.