S C R I P T B A K E R

Loading

Ajax based Yii login form

Ajax helps us creating fancy forms, Ajax based forms boost user experience. Yii framework provides ajax validation but at the end form is submitted without ajax and our page goes refreshed.

Read More

How to save multiple related models in Yii [Complete Solution]

Scenario: You are in a situation where you have two related tables a Parent and a child table. You need to create a user experience in which user presses Save button only once, meaning by, user enters all the data in parent model fields, then enters data in all child model fields, optionally generates more … Continue reading “How to save multiple related models in Yii [Complete Solution]”

Read More

Yii 1.1: Behaviors & Events

Behaviors & Events provide endless possibilities and unbelievable flexibility, but as current Yii documentation does not give more than a few examples, it might be difficult to fully understand their internals and requirements. It should be noted that they do mostly the same thing. You can attach behaviors and event handlers to components to modify … Continue reading “Yii 1.1: Behaviors & Events”

Read More

Yii password, repeat password fields

Yii framework has awesome input validation mechanism, one of the many validation rules is “compare” rule. You can utilize it for creating confirmation fields to verify user input. Its a good practice to get password input twice while creating signup and change password forms.

Read More

Switch Yii layout based on user role

You can assign different layouts to different users using following filter class 1. Add LayoutFilter.php to your protected/components/ folder 2. Update protected/components/Controller.php and add following filters 3. Update all controllers and add following filters

Read More