The popular CListView and CGridView widgets each take a data provider and iterate over each data object produced, calling the user's code to render each row one at a time, and most are familiar with the use of the $data variable to represent the current model object or array.
Updated 6 years ago by Stamm – Tips – 7 comments – viewed 22,186 times
( +21 / -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.
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.
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?