Yii Framework Forum: public validate method for activeform - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

public validate method for activeform Rate Topic: -----

#1 User is offline   alex-w 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 223
  • Joined: 25-November 10

Posted 05 April 2011 - 07:29 AM

I've got an ActiveForm with client validation enabled and want to submit it using ajaxSubmitButton();
The problem is the submit button will happily fire regardless of the state of validation.

I think a callable validate() function would be good (could only work for client side validation).
It would display any errors then return a boolean value indicating if the form is valid.

This would allow the use of beforeSend in the ajax button.
0

#2 User is offline   riyazMuhammed 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 13-September 12
  • Location:Bangalore

Posted 08 October 2012 - 06:56 AM

View Postalex-w, on 05 April 2011 - 07:29 AM, said:

I've got an ActiveForm with client validation enabled and want to submit it using ajaxSubmitButton();
The problem is the submit button will happily fire regardless of the state of validation.

I think a callable validate() function would be good (could only work for client side validation).
It would display any errors then return a boolean value indicating if the form is valid.

This would allow the use of beforeSend in the ajax button.


Hi :)
Did you find the solution for this ? If Yes can you plz plz plz post ?
0

#3 User is offline   hehbhehb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 50
  • Joined: 24-February 12

Posted 09 October 2012 - 06:33 AM

you can use afterValidate option.


<?php

Yii::app()->clientScript->registerScript('search', "
function refresh_gridview(form, data, hasError)
{
if (!hasError) {
$.fn.yiiGridView.update('$gridview_id', {
data: $(form).serialize()
});
}
}

");

$form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'id'=>'form_id',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true,'afterValidate'=>'js:refresh_gridview'),

));
?>
...
0

#4 User is offline   riyazMuhammed 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 13-September 12
  • Location:Bangalore

Posted 03 November 2012 - 07:29 AM

afterValidate is not getting fired for me when I am using ajaxSubmitButton !

So I came up myself with the simplest solution to this problem here

http://www.yiiframew...axsubmitbutton/
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users