Wiki

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

CGridView: Display the full record (actionView) in a CJuiDialog

Created 4 years ago by JobloTips7 comments – viewed 41,599 times – ( +15 ) – version 1.1
If you show a model (with a lot of attributes) partially in a CGridView, it can be helpful when the user can take a quick look at the full record with all attributes without displaying the view as a page and afterwards returning back to the gridview.

Adding Yii Search to Your Browser Search Box

Created 5 years ago by qiangTips1 comment – viewed 41,479 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 yiiframework.com. 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

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 3 years ago by Rajith RTips20 comments – viewed 40,356 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 .

Update two models with one view

Created 4 years ago by sensorarioTips11 comments – viewed 39,050 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

A simple action for CJuiAutoComplete

Created 5 years ago by tydeas_drTips9 comments – viewed 36,575 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?

An easy way to display a success page using flash messages

Created 5 years ago by qiangTips2 comments – viewed 36,334 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.

Display a nice exception message on ajax requests

Created 4 years ago by Maurizio Domba CerinTips3 comments – viewed 35,928 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 4 years ago by fsbTips5 comments – viewed 35,741 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.

Putting Function To Be Called In View

Created 5 years ago by junxiongTips2 comments – viewed 33,713 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

Using CJuiDialog to edit rows in a CGridView

Created 5 years ago by Russell EnglandTips8 comments – viewed 32,365 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.