DetailView captionOptions & contentOptions attributes

This commit is contained in:
githubjeka
2016-10-04 16:53:05 +03:00
committed by SilverFire - Dmitry Naumenko
parent 483e09dc4a
commit 76ced661b2
6 changed files with 55 additions and 13 deletions

View File

@ -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
],
]);
```

View File

@ -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
],
]);
```