Monday 15 June 2015

php - The dialog can't pop up when the date validation is invalid -


I am a new UI user, I have a problem when I want to create a website is a part of my website which is user input Requires a start date and end date, I have a function, if the last date is set before the start date, then it will show a dialog box to automatically warn the user, but I can not do this Do you have any idea to do this?

Here is my code of two date text fields:

  & lt; Td> Start & lt ;? Php $ this- & gt; Widgets ('Zii.widgets.jui.CJuiDatePicker', array ('name' = & gt; 'COURSE_START_DATE', 'model' => $ Cmodel, 'attribute' => 'COURSE_START_DATE', 'languages' = & Gt; Yii:: app () - & gt; language == 'en_us',' options' => array ('Showenim' => gt; 'fold', // 'show' (default), ' SlideDown ',' Fadein 'button,' '' '' '' '' '' '' ',' Button ',' 'Focus'' 'Button' '' '' Button Text '= & gt; Yii :: T (' I ',' Calendar '),' Button Image '& gt; Yii :: App () - & gt; Request- & gt; BaseUp.' / Images / Calendar.png ',' Button image only '= & gt; true,))? & Gt; & lt; / td & gt; & lt; td & gt; Finish & lt ;? php $ this- & gt; ; Widgets ('zii.widgets.jui.CJuiDatePicker', array ('name' = & gt; 'COURSE_EN' D_DATE ',' Model '= & gt; $ Cmodel,' attribute '=>' COURSE_END_DATE ',' language '=> Yii :: app () - & gt; language ==' en_us ',' options '= & Gt; Array (' Showenem '= & gt;' Guna ', //' Show '(default),' SlideDown ',' Fadein ',' Show '' = ',' Button ', / / 'Focus',' Button ',' Both '' ButtonText = & gt; Yii :: T ('I', 'Calendar'), 'Button Image' = & gt; Yii :: app () - & gt; Request-> Baseball '/ Images / calendar.png', 'Button image only' = & gt; This is the truth,),)); ? & Gt;    

If you are really new to yii, you will learn a bunch of stuff :

How to verify AJAX and client in Yii:

In your form, you must indicate that AJAX and client can be verified. Here's an example:

  & lt ;? Php $ form = $ this- & gt; Start the widget ('Cactiform', array ('id' = & gt; 'contact form', 'enabled ajax validity' = & gt; true, // it turns AJAX verification 'enabled client validity' => ; True, // it turns on client verification);? & Gt;   

2 Enable AJAX accreditation in your controller < P> For example, in your controller action call:

  $ this-> display agax validity ($ model);  with  

: < / P>

  secure function Demonstrate ajoxualdition ($ model) {if (isset ($ _ POST ['ajax']) and $ _POST ['ajax'] === 'contact form') {echo cactiform :: validate ($ model); Yii :: app () -> end ();}}   

3 Create verification rules in your model

Then you You will need to create verification rules that will compare your two values, to do this, to the default operator, for example & gt; So in your model you will have something like this:

  public Hnkshn rules () {return array (// than your other rules array ( 'COURSE_END_DATE' Compare 'to' = & gt; 'COURSE_START_DATE', 'operator' = & gt; '& Gt;');); }    

No comments:

Post a Comment