Wiki

Displaying 531-540 of 753 result(s).

Using cache in CActiveDataProvider

Created 3 years ago by StammTips7 comments – viewed 17,467 times – ( +21 ) – version 1.1
First param in CActiveDataProvider could be a string with model name or instance of class. So, you may use CActiveRecord::cache() for cache, but you need set third param to 2, because you should cache 2 queries: counting and get data.

Using filters with CGridView and CArrayDataProvider

Created 3 years ago by marcovtwoutHow-tos32 comments – viewed 57,234 times – ( +21 ) – version 1.1
Using filters on CGridView with CActiveDataProvider is easy, but with CArrayDataProvider it is a bit tricky.

Avoiding duplicate script download when using CActiveForm on Ajax calls

Created 3 years ago by Antonio RamirezTutorials2 comments – viewed 17,266 times – ( +12 / -1 ) – version 1.1
Sometimes the active form we wish to use to edit/add a new element on our database is too small and we believe that is much better to use an AJAX'ed dialog/slide form rather than reloading the page to just display one or two fields.

Customizing Yii's formatting rules (extending CFormatter)

Created 3 years ago by HaenselTips0 comments – viewed 14,645 times – ( +14 ) – version 1.1
CFormatter is one of Yii's core components and used to format values displayed in widgets like CGridView or CDetailView. All classic formats like numbers, text, urls or datetime are supported but you may have to use a formatting rule that isn't built in. Let's say we want to display arrays of strings (like tags associated with a product model). When using CDetailView we would usually make use of PHPs implode function to create a simple string value of all values in the $product->tags array.

Filter / Search with CListView

Created 3 years ago by JohnPollardHow-tos9 comments – viewed 36,570 times – ( +29 ) – version 1.1
This is what I did. Its the EASIEST solution that I know of. I just reused the advanced search done in CGridView.

Display a nice exception message on ajax requests

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

Guidelines for good schema design

Created 4 years ago by Steve FriedlTips15 comments – viewed 69,111 times – ( +142 ) – version 1.1
Virtually all Yii applications are built on top of a database, and though Yii is very flexible in how it addresses your DB, some design choices make things more convenient than others.

Run Yiic directly from your app without a shell

Created 4 years ago by jacmoeHow-tos6 comments – viewed 26,665 times – ( +18 ) – version 1.1
Sometimes it would be nice if we could run yiic from an action, for example a migrate database button in our admin panel. Or because you are on a host which doesn't have shell access. Or maybe you are not allowed run popen or exec.

an easy way to required multi columns(At least one cannot be blank)

Created 4 years ago by 1065227709Tips0 comments – viewed 5,581 times – ( +2 ) – version 1.1
in model add the following code:
tags: rules

Using a CDbDataReader (sql query result) in a zii widget (such as CGridView or CListView)

Created 4 years ago by Revelis Luc BonninHow-tos2 comments – viewed 23,931 times – ( +9 / -1 ) – version 1.1
If in your application you have to proceed to a complex SQL query that is not associated to a model, you will use CDbDataReader like it is described in the Yii documentation. An example could be