Difference between #2 and #3 of
Enforcing "You must agree" requirements in forms

Revision #3 has been created by Steve Friedl on Jan 23, 2011, 3:53:32 AM with the memo:

Expanded on the name of the per-model attribute to remind the user that it can be called anything - "iagree" is not some special keyword
« previous (#2)


Title unchanged

Enforcing "You must agree" requirements in forms

Category unchanged


Yii version unchanged

Tags unchanged


Content changed

* I agree that Yii is the best MVC framework ever
* I am over 18 years of age

In this case, the checkbox (implemented in the usual way in a form) warrants a validator that enforces this condition, and it can be done with the built-in `compare` validator along with a custom message:

Here, the model's `iagree` attribute
 (which could be named anything as your database or form dictate) can be attached to a form, and validation will be applied to it:

class SomeModel extends CActiveRecord {
public function rules()
25 0
Viewed: 25 577 times
Version: 1.1
Category: How-tos
Written by: Steve Friedl
Last updated by: Steve Friedl
Created on: Jan 20, 2011
Last updated: 7 years ago
Update Article


View all history