background preloader

View

Facebook Twitter

View. A view is a PHP script consisting mainly of user interface elements.

View

It can contain PHP statements, but it is recommended that these statements should not alter data models and should remain relatively simple. In the spirit of separating of logic and presentation, large chunks of logic should be placed in controllers or models rather than in views. CController Render. Look up a class, method, property or event CController manages a set of actions which deal with the corresponding user requests.

CController Render

Through the actions, CController coordinates the data flow between models and views. CWidget. Look up a class, method, property or event CWidget is the base class for widgets.

CWidget

A widget is a self-contained component that may generate presentation based on model data. It can be viewed as a micro-controller that embeds into the controller-managed views. Compared with controller, a widget has neither actions nor filters. Usage is described at CBaseController and CBaseController::widget. CBaseListView. Look up a class, method, property or event CBaseListView is the base class for CListView and CGridView.

CBaseListView

CGridView. Look up a class, method, property or event CGridView displays a list of data items in terms of a table.

CGridView

Each row of the table represents the data of a single data item, and a column usually represents an attribute of the item (some columns may correspond to complex expression of attributes or static text). CGridView supports both sorting and pagination of the data items. The sorting and pagination can be done in AJAX mode or normal page request. A benefit of using CGridView is that when the user browser disables JavaScript, the sorting and pagination automatically degenerate to normal page requests and are still functioning as expected. CGridColumn. Look up a class, method, property or event CGridColumn is the base class for all grid view column classes.

CGridColumn

A CGridColumn object represents the specification for rendering the cells in a particular grid view column. In a column, there is one header cell, multiple data cells, and an optional footer cell. Child classes may override renderHeaderCellContent, renderDataCellContent and renderFooterCellContent to customize how these cells are rendered. CButtonColumn. Look up a class, method, property or event CButtonColumn represents a grid view column that renders one or several buttons.

CButtonColumn

By default, it will display three buttons, "view", "update" and "delete", which triggers the corresponding actions on the model of the row. By configuring buttons and template properties, the column can display other buttons and customize the display order of the buttons. Public Properties Hide inherited properties. Using CButtonColumn. Introduction ¶ CGridView is a one of most flexible widgets in Yii and example its flexibility is CButtonColumn used to build buttons for steering model in each grid row.

Using CButtonColumn

Here in this how-to we will explain ways user can customize CButtonColumn to flexibly fit it to its needs. Basic customization ¶ In default look CButtonColumn contains three buttons in this order: {view}, {update} and {delete}. Their meaning and behaviour should be obvious. The easiest way to customize look and behaviour of them is to use series of CButtonColumn properties, like: updateButtonImageUrl (path to image for update button), updateButtonLabel (label for the update button; not HTML-encoded), updateButtonOptions (HTML options for this button, used in the way as many htmlOptions property for many widgets) and updateButtonUrl (a PHP expresion that is evaluated for button and whose result is used as the URL). CActiveForm. Look up a class, method, property or event CActiveForm provides a set of methods that can help to simplify the creation of complex and interactive HTML forms that are associated with data models.

CActiveForm

The 'beginWidget' and 'endWidget' call of CActiveForm widget will render the open and close form tags. Most other methods of CActiveForm are wrappers of the corresponding 'active' methods in CHtml. Calling them in between the 'beginWidget' and 'endWidget' calls will render text labels, input fields, etc. For example, calling CActiveForm::textField would generate an input field for a specified model attribute. CJuiWidget. CJuiDatePicker. Look up a class, method, property or event CJuiDatePicker displays a datepicker.

CJuiDatePicker

CJuiDatePicker encapsulates the JUI datepicker plugin. To use this widget, you may insert the following code in a view: $this->widget('zii.widgets.jui.CJuiDatePicker',array( 'name'=>'publishDate', // additional javascript options for the date picker plugin 'options'=>array( 'showAnim'=>'fold', ), 'htmlOptions'=>array( 'style'=>'height:20px;' ), )); By configuring the options property, you may specify the options that need to be passed to the JUI datepicker plugin.

jQuery Datepicker. CJuiDatePicker in CActiveForm. CJuiDatePicker/CActiveForm Yii Framework CJuiDatePicker Example For many of our web applications, we utilize the Yii Framework extensively. A great feature of the framework is the CActiveForm, which allows you to link up your Model to your View in a very easy manner. (See Model-View-Controller Architecture on Wikipedia for a good explanation of this concept.) If you also use the Yii Framework, you might find yourself in a dilemma that we recently experienced. CJuiDatePicker Yii Forum. CTreeView. Look up a class, method, property or event CTreeView displays a tree view of hierarchical data. It encapsulates the excellent tree view plugin for jQuery ( To use CTreeView, simply sets data to the data that you want to present and you are there. CTreeView also supports dynamic data loading via AJAX.

To do so, set url to be the URL that can serve the tree view data upon request. Public Properties Hide inherited properties. CHtml Wiki. "By Example" cookbook pages will provide coding examples for many of the commonly used classes within Yii. We will try to provide as many usage examples as possible for keep these pages as helpful as possible. Smarthead will be pulling these from the forum when he is not finding the answers on his own. Please request examples using the comments below or ask for an example in the forum. CHtml.

Look up a class, method, property or event CHtml is a static class that provides a collection of helper methods for creating HTML views. Property Details public static string $afterRequiredLabel; the HTML code to be appended to the required label. public static string $beforeRequiredLabel; the HTML code to be prepended to the required label. public static boolean $closeSingleTags; whether to close single tags. Public static integer $count; CForm. Form Builder. When creating HTML forms, we often find that we are writing a lot of repetitive view code which is difficult to be reused in a different project. For example, for every input field, we need to associate it with a text label and display possible validation errors. To improve the reusability of these code, we can use the form builder feature.