ajaxvalidationmessages Shows validation messages coming from an AJAX-called action.

  1. Changelog
  2. Requirements
  3. Usage
  4. SHA1 Checksums:
  5. Resources

EAjaxValidationMessages loads a jQuery plugin which show the validation error messages and changes the CSS class for the error class. It also contains a function to hide those errors and restore the form to its original state.

Changelog

  • 20110916 - 1.1 - summary is shown if it exists.

Requirements

  • Yii 1.8.0
  • jQuery

Usage

In your AJAX-called action validate like this:

$errors = CActiveForm::validate($model);
if ($errors !== '[]') {
   echo $errors;
   Yii::app()->end();
}

In your view include the widget:

<?php $this->widget('application.extensions.ajaxvalidationmessages.EAjaxValidationMessages',
                    array(
                       'errorCssClass'=>'clsError',
                       'errorMessageCssClass'=>'clsErrorMessage',
                       'errorSummaryCssClass'=>'clsErrorSummary')); ?>

In your view, in your AJAX callbacks for ajaxSubmitButtons which validate, call the plugin's methods:

'success'=>"function(html) {
    if (html.indexOf('{')==0) {
       jQuery('#the-form').ajaxvalidationmessages('show', html);
    }
    else {
       jQuery('#the-form').ajaxvalidationmessages('hide');
    }
 }",
 'error'=>"function(html) {
    jQuery('#the-form').ajaxvalidationmessages('hide');
 }",

where the-form is the id of your form.

SHA1 Checksums:

  • 74eef562a616d68302f1279befeafd3fac45007a ajaxvalidationmessages-1.0.tar.bz2

Resources

4 0
12 followers
1 257 downloads
Yii Version: 1.1
License: MIT
Category: Error Handling
Developed by: MetaYii
Created on: Sep 15, 2011
Last updated: 13 years ago

Downloads

show all

Related Extensions