

$index: integer, the zero-based index of the data item in the items array returned by the data provider.$key: mixed, the key value associated with the data item.Additionally the following variables are available: In the view file above, the current data model is available as $model. The _post view file could contain the following: title) ?> text) ?> Information to end user and to create data managing UI.Ī typical usage is as follows: use yii\ widgets\ ListView Since it provides features such as pagination, sorting and filtering out of the box, it is handy both to display The ListView widget is used to display data from a data provider.Įach data model is rendered using the specified view file. Value calculations in case it evaluates to false: echo DetailView::widget([ For example when visible is specified and you want to prevent However some cases can make using of closure useful. $model is the only one model for display and available in view as a variable. So most of the time there is no need for using closure since Remember that unlike yii\widgets\GridView which processes a set of models,ĭetailView processes just one. 'created_at:datetime', // creation date formatted as datetime

'contentOptions' =>, // HTML attributes to customize value tag 'captionOptions' =>, // HTML attributes to customize label tag [ // the owner name of the model 'label' => 'Owner', 'title', // title attribute (in plain text) 'description:html', // description attribute formatted as HTML See the formatter section for available formatting options.Ī typical usage of DetailView is as follows: echo DetailView::widget([ The model can be either an instance or subclass of yii\base\Model such as an active record or an associative array.ĭetailView uses the $attributes property to determine which model attributes should be displayed and how they each model attribute is displayed as a row in a table). It is best used for displaying a model in a regular format (e.g. The DetailView widget displays the details of a single data model. Providing features like pagination, sorting and filtering. ListView and GridView can be used to display a list or table of data records While the DetailView widget can be used to display data for a single record, Yii provides a set of widgets that can be used to display data.
