Articles in category "tips", sorted by viewsX
Displaying 21-30 of 149 result(s).

Adding Yii Search to Your Browser Search Box

Created 4 years ago by qiangTips1 comment – viewed 37,290 times – ( +28 ) – version 1.1
The official Yii project site now supports OpenSearch. This means you can customize your browser's search box to enable direct search of the content in For example, by entering a Yii class name in the browser's search box, the corresponding class API page will be shown in the browser.
tags: search

Update two models with one view

Created 3 years ago by sensorarioTips11 comments – viewed 36,341 times – ( +10 / -2 ) – version 1.1
Suppose to have two models: Users and Emails. You do not want to store email in a Users model. And User can have 0 or many emails. This is the form generated to create a new user (just username).
tags: database, model, view, form

Assigning dynamic roles to a user Using yii Rights module at the time of user creation and using some special advanced features of yii rights

Created 2 years ago by Rajith RTips20 comments – viewed 35,522 times – ( +11 / -8 ) – version 1.1
After Installing Yii Users and Rights to Newly Created Yii app we have to assign dynamic roles to a user at the time of user creation .

A simple action for CJuiAutoComplete

Created 4 years ago by tydeas_drTips9 comments – viewed 33,441 times – ( +17 / -1 ) – version 1.1
More or less I use auto-complete field for a form. CJuiAutoComplete is a yii widget for this purposes. The common use case is to make an ajax request and retrieve a list from the database. So in this case you have to write a controller action to return you a json encoded list. What if I had a generic action to do this work for me?

Display a nice exception message on ajax requests

Created 4 years ago by Maurizio Domba CerinTips3 comments – viewed 32,137 times – ( +13 ) – version 1.1
When an exception is thrown in our code like
tags: error, exception

1:n relations sometimes require CDbCriteria.together

Created 3 years ago by fsbTips5 comments – viewed 31,951 times – ( +16 ) – version 1.1
There are situations in which Active Record will generate nonsense queries from what a nieve Yii user might think is reasonable code. One such situation is a CActiveDataProvider using CDbCriteria to get data from parent and 1:n child table with a condition on the child table.

An easy way to display a success page using flash messages

Created 4 years ago by qiangTips2 comments – viewed 31,727 times – ( +28 ) – version 1.1
We often need to display a success page after the user has submitted a form without problem. We may show some welcome message after a user registers a new account. There are many ways to implement this workflow. In this article, I will explain a method that exploits flash messages.

Yii 2 list of path aliases available with default basic and advanced app.

Created about a year ago by Kartik VTips1 comment – viewed 30,838 times – ( +42 / -5 ) – version 2.0
If you are coming over from Yii 1.x to Yii 2, and already read this guide, you may note that namespaces are very important in Yii 2 to identify classes. But do you know the list of seeded path aliases that come shipped with a basic or advanced app? Here is my attempt to list them.

Using CJuiDialog to edit rows in a CGridView

Created 4 years ago by Russell EnglandTips8 comments – viewed 30,426 times – ( +4 / -1 ) – version 1.1
I have a CGridView with a list of clients/events. For each row (EventClient) I wanted a quick edit dialog.

Putting Function To Be Called In View

Created 4 years ago by junxiongTips2 comments – viewed 29,712 times – ( +6 / -1 ) – version 1.1
Sometimes we need some complicated view to be displayed (such as generating complicated table). Most people suggest that in MVC the View must be as simple as possible (don't have too much loops, etc). So what we have to do is to hide away the complex code by putting it at somewhere else. The following are few places options to keep the function:
tags: view, render