News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Refulz Blog:
Yii Framework - Scenarios for Conditional Multiple Validation Rules
April 24, 2012 @ 09:18:49

On the Refulz blog there's a post showing you how to set up conditional multiple validation rules in a Yii framework application.

I am yet to write the last article of the Yii Session series. I just decided to write something about the scenarios in the Validation feature of Yii framework. Scenarios are a very useful tool for adding different validations rules for different cases on the same model. In a real life situation, you would require one validation rule for user registration but the same rule might not be applicable to the User login. Scenarios help you define validation rules for different situations within same model.

He shows you how to set up a "rules()" method in your model and a few validation configurations inside it - ensuring the password and email are set, checking the length of the password, etc. Then, by calling the "validate()" method on the model, you can easily apply these rules and check the pass/fail status.

0 comments voice your opinion now!
yii framework validation model rules tutorial


blog comments powered by Disqus

Similar Posts

NETTUTS.com: CodeIgniter From Scratch: Day 5 – CRUD

Developer.com: Fat Models and Skinny Controllers Bring Out the Best in Your MVC Framework

Elated.com: Object-Oriented PHP: Autoloading, Serializing, and Querying Objects

DevShed: Using Timers to Benchmark PHP Applications

Ralph Schindler's Blog: Compiling Gearman (or anything) for Zend Server CE on Snow Leopard


Community Events











Don't see your event here?
Let us know!


application symfony2 composer podcast code hack language framework opinion component performance install security release facebook introduction unittest overview hhvm package

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework