Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CBaseListView
  • CBreadcrumbs
  • CDetailView
  • CListView
  • CMenu
  • CPortlet
  • MobileActivityFeedListView
  • RecordIndexListView
  • TopicsListView
  • Overview
  • Package
  • Class
  • Tree

Class CDetailView

CDetailView displays the detail of a single data model.

CDetailView is best used for displaying a model in a regular format (e.g. each model attribute is displayed as a row in a table.) The model can be either an instance of CModel or an associative array.

CDetailView uses the CDetailView::$attributes property to determines which model attributes should be displayed and how they should be formatted.

A typical usage of CDetailView is as follows:

$this->widget('zii.widgets.CDetailView', array(
    'data'=>$model,
    'attributes'=>array(
        'title',             // title attribute (in plain text)
        'owner.name',        // an attribute of the related object "owner"
        'description:html',  // description attribute in HTML
        array(               // related city displayed as a link
            'label'=>'City',
            'type'=>'raw',
            'value'=>CHtml::link(CHtml::encode($model->city->name),
                                 array('city/view','id'=>$model->city->id)),
        ),
    ),
));
CComponent
Extended by CBaseController
Extended by CWidget
Extended by CDetailView
Package: zii\widgets
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1
Located at x2engine/framework/zii/widgets/CDetailView.php
Methods summary
public
# init( )

Initializes the detail view. This method will initialize required property values.

Initializes the detail view. This method will initialize required property values.

Overrides

CWidget::init()
public
# run( )

Renders the detail view. This is the main entry of the whole detail view rendering.

Renders the detail view. This is the main entry of the whole detail view rendering.

Overrides

CWidget::run()
protected
# renderItem( array $options, string $templateData )

This method is used by run() to render item row

This method is used by run() to render item row

Parameters

$options
array
$options config options for this item/attribute from CDetailView::$attributes
$templateData
string
$templateData data that will be inserted into CDetailView::$itemTemplate

Since

1.1.11
public CFormatter
# getFormatter( )

Returns

CFormatter
the formatter instance. Defaults to the 'format' application component.
public
# setFormatter( CFormatter $value )

Parameters

$value
CFormatter
$value the formatter instance
Methods inherited from CWidget
__construct(), actions(), getController(), getId(), getOwner(), getViewFile(), getViewPath(), render(), setId()
Methods inherited from CBaseController
beginCache(), beginClip(), beginContent(), beginWidget(), createWidget(), endCache(), endClip(), endContent(), endWidget(), renderFile(), renderInternal(), widget()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public mixed $data
#

the data model whose details are to be displayed. This can be either a CModel instance (e.g. a CActiveRecord object or a CFormModel object) or an associative array.

the data model whose details are to be displayed. This can be either a CModel instance (e.g. a CActiveRecord object or a CFormModel object) or an associative array.

public array $attributes
#

a list of attributes to be displayed in the detail view. Each array element represents the specification for displaying one particular attribute.

An attribute can be specified as a string in the format of "Name:Type:Label". Both "Type" and "Label" are optional.

"Name" refers to the attribute name. It can be either a property (e.g. "title") or a sub-property (e.g. "owner.username").

"Label" represents the label for the attribute display. If it is not given, "Name" will be used to generate the appropriate label.

"Type" represents the type of the attribute. It determines how the attribute value should be formatted and displayed. It is defaulted to be 'text'. "Type" should be recognizable by the formatter. In particular, if "Type" is "xyz", then the "formatXyz" method of formatter will be invoked to format the attribute value for display. By default when CFormatter is used, these "Type" values are valid: raw, text, ntext, html, date, time, datetime, boolean, number, email, image, url. For more details about these types, please refer to CFormatter.

An attribute can also be specified in terms of an array with the following elements:
  • label: the label associated with the attribute. If this is not specified, the following "name" element will be used to generate an appropriate label.
  • name: the name of the attribute. This can be either a property or a sub-property of the model. If the below "value" element is specified, this will be ignored.
  • value: the value to be displayed. If this is not specified, the above "name" element will be used to retrieve the corresponding attribute value for display. Note that this value will be formatted according to the "type" option as described below. This can also be an anonymous function whose return value will be used as a value. The signature of the function should be <span class="php-keyword1">function</span>(<span class="php-var">$data</span>) where data refers to the CDetailView::$data property of the detail view widget.
  • type: the type of the attribute that determines how the attribute value would be formatted. Please see above for possible values.
  • cssClass: the CSS class to be used for this item. This option is available since version 1.1.3.
  • template: the template used to render the attribute. If this is not specified, CDetailView::$itemTemplate will be used instead. For more details on how to set this option, please refer to CDetailView::$itemTemplate. This option is available since version 1.1.1.
  • visible: whether the attribute is visible. If set to <span class="php-keyword1">false</span>, the table row for the attribute will not be rendered. This option is available since version 1.1.5.

a list of attributes to be displayed in the detail view. Each array element represents the specification for displaying one particular attribute.

An attribute can be specified as a string in the format of "Name:Type:Label". Both "Type" and "Label" are optional.

"Name" refers to the attribute name. It can be either a property (e.g. "title") or a sub-property (e.g. "owner.username").

"Label" represents the label for the attribute display. If it is not given, "Name" will be used to generate the appropriate label.

"Type" represents the type of the attribute. It determines how the attribute value should be formatted and displayed. It is defaulted to be 'text'. "Type" should be recognizable by the formatter. In particular, if "Type" is "xyz", then the "formatXyz" method of formatter will be invoked to format the attribute value for display. By default when CFormatter is used, these "Type" values are valid: raw, text, ntext, html, date, time, datetime, boolean, number, email, image, url. For more details about these types, please refer to CFormatter.

An attribute can also be specified in terms of an array with the following elements:
  • label: the label associated with the attribute. If this is not specified, the following "name" element will be used to generate an appropriate label.
  • name: the name of the attribute. This can be either a property or a sub-property of the model. If the below "value" element is specified, this will be ignored.
  • value: the value to be displayed. If this is not specified, the above "name" element will be used to retrieve the corresponding attribute value for display. Note that this value will be formatted according to the "type" option as described below. This can also be an anonymous function whose return value will be used as a value. The signature of the function should be <span class="php-keyword1">function</span>(<span class="php-var">$data</span>) where data refers to the CDetailView::$data property of the detail view widget.
  • type: the type of the attribute that determines how the attribute value would be formatted. Please see above for possible values.
  • cssClass: the CSS class to be used for this item. This option is available since version 1.1.3.
  • template: the template used to render the attribute. If this is not specified, CDetailView::$itemTemplate will be used instead. For more details on how to set this option, please refer to CDetailView::$itemTemplate. This option is available since version 1.1.1.
  • visible: whether the attribute is visible. If set to <span class="php-keyword1">false</span>, the table row for the attribute will not be rendered. This option is available since version 1.1.5.
public string $nullDisplay
#

the text to be displayed when an attribute value is null. Defaults to "Not set".

the text to be displayed when an attribute value is null. Defaults to "Not set".

public string $tagName 'table'
#

the name of the tag for rendering the detail view. Defaults to 'table'. If set to null, no tag will be rendered.

the name of the tag for rendering the detail view. Defaults to 'table'. If set to null, no tag will be rendered.

See

CDetailView::$itemTemplate
public string $itemTemplate "<tr class=\"{class}\"><th>{label}</th><td>{value}</td></tr>\n"
#

the template used to render a single attribute. Defaults to a table row. These tokens are recognized: "{class}", "{label}" and "{value}". They will be replaced with the CSS class name for the item, the label and the attribute value, respectively.

the template used to render a single attribute. Defaults to a table row. These tokens are recognized: "{class}", "{label}" and "{value}". They will be replaced with the CSS class name for the item, the label and the attribute value, respectively.

See

CDetailView::$itemCssClass
public array $itemCssClass array('odd','even')
#

the CSS class names for the items displaying attribute values. If multiple CSS class names are given, they will be assigned to the items sequentially and repeatedly. Defaults to <span class="php-keyword1">array</span>(<span class="php-quote">'odd'</span>, <span class="php-quote">'even'</span>).

the CSS class names for the items displaying attribute values. If multiple CSS class names are given, they will be assigned to the items sequentially and repeatedly. Defaults to <span class="php-keyword1">array</span>(<span class="php-quote">'odd'</span>, <span class="php-quote">'even'</span>).

public array $htmlOptions array('class'=>'detail-view')
#

the HTML options used for CDetailView::$tagName

the HTML options used for CDetailView::$tagName

public string $baseScriptUrl
#

the base script URL for all detail view resources (e.g. javascript, CSS file, images). Defaults to null, meaning using the integrated detail view resources (which are published as assets).

the base script URL for all detail view resources (e.g. javascript, CSS file, images). Defaults to null, meaning using the integrated detail view resources (which are published as assets).

public string $cssFile
#

the URL of the CSS file used by this detail view. Defaults to null, meaning using the integrated CSS file. If this is set false, you are responsible to explicitly include the necessary CSS file in your page.

the URL of the CSS file used by this detail view. Defaults to null, meaning using the integrated CSS file. If this is set false, you are responsible to explicitly include the necessary CSS file in your page.

Properties inherited from CWidget
$actionPrefix, $skin
Magic properties summary
public CFormatter $formatter
#

The formatter instance. Defaults to the 'format' application component.

The formatter instance. Defaults to the 'format' application component.

Magic properties inherited from CWidget
$controller, $id, $owner, $viewPath
API documentation generated by ApiGen 2.8.0