mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
DetailView captionOptions & contentOptions attributes
This commit is contained in:
committed by
SilverFire - Dmitry Naumenko
parent
483e09dc4a
commit
76ced661b2
@ -26,13 +26,15 @@ DetailView использует свойство [[yii\widgets\DetailView::$attr
|
||||
echo DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'title', // title свойство (обычный текст)
|
||||
'description:html', // description свойство, как HTML
|
||||
[ // name свойство зависимой модели owner
|
||||
'title', // title свойство (обычный текст)
|
||||
'description:html', // description свойство, как HTML
|
||||
[ // name свойство зависимой модели owner
|
||||
'label' => 'Owner',
|
||||
'value' => $model->owner->name,
|
||||
'value' => $model->owner->name,
|
||||
'contentOptions' => ['class' => 'bg-red'], // настройка HTML атрибутов для тега, соответсвующего value
|
||||
'captionOptions' => ['tooltip' => 'Tooltip'], // настройка HTML атрибутов для тега, соответсвующего label
|
||||
],
|
||||
'created_at:datetime', // дата создания в формате datetime
|
||||
'created_at:datetime', // дата создания в формате datetime
|
||||
],
|
||||
]);
|
||||
```
|
||||
|
||||
@ -24,13 +24,15 @@ A typical usage of DetailView is as follows:
|
||||
echo DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'title', // title attribute (in plain text)
|
||||
'description:html', // description attribute formatted as HTML
|
||||
[ // the owner name of the model
|
||||
'title', // title attribute (in plain text)
|
||||
'description:html', // description attribute formatted as HTML
|
||||
[ // the owner name of the model
|
||||
'label' => 'Owner',
|
||||
'value' => $model->owner->name,
|
||||
'value' => $model->owner->name,
|
||||
'contentOptions' => ['class' => 'bg-red'], // to HTML customize attributes of value tag
|
||||
'captionOptions' => ['tooltip' => 'Tooltip'], // to HTML customize attributes of label tag
|
||||
],
|
||||
'created_at:datetime', // creation date formatted as datetime
|
||||
'created_at:datetime', // creation date formatted as datetime
|
||||
],
|
||||
]);
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user