Class kartik\detail\DetailView
Inheritance | kartik\detail\DetailView » yii\widgets\DetailView » yii\base\Widget » yii\base\Component » yii\base\BaseObject |
---|---|
Implements | kartik\base\BootstrapInterface, yii\base\Configurable, yii\base\ViewContextInterface |
Uses Traits | kartik\base\BootstrapTrait, kartik\base\TranslationTrait, kartik\base\WidgetTrait |
Available since version | 1.0 |
DetailView displays the detail of a single data $model. This widget enhances the yii\widgets\DetailView widget with ability to edit detail view data, configure multi columnar layouts, merged section headers, and various other bootstrap styling enhancements.
DetailView is best used for displaying a model in a regular format (e.g. each model attribute is displayed as a row in a table or one can define multiple columns by defining child attributes in each attribute configuration.) The model can be either an instance of yii\base\Model or an associative array.
DetailView uses the $attributes property to determines which model attributes should be displayed and how they should be formatted.
A typical usage of DetailView is as follows:
echo DetailView::widget([
'model' => $model,
'attributes' => [
'title', // title attribute (in plain text)
'description:html', // description attribute in HTML
[ // the owner name of the model
'label' => 'Owner',
'value' => $model->owner->name,
],
'created_at:datetime', // creation date formatted as datetime
],
]);
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$alertContainerOptions | array | The HTML attributes for the alert block container which will display any alert messages received on update or delete of record. | kartik\detail\DetailView |
$alertMessageSettings | array | The alert flash message settings. | kartik\detail\DetailView |
$alertWidgetOptions | array | The widget settings for each bootstrap alert displayed in the alert container block. | kartik\detail\DetailView |
$arrayValueToString | boolean | Whether to convert array values to string using print_r . |
kartik\detail\DetailView |
$attributes | array | A list of attributes to be displayed in the detail view. | kartik\detail\DetailView |
$autoIdPrefix | string | The prefix to the automatically generated widget IDs. | yii\base\Widget |
$baseSourcePath | string|false | Get parsed base source path based on $sourcePath setting. If $sourcePath is not set, it will return the current working directory of this widget class. | kartik\base\WidgetTrait |
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component. | yii\base\Component |
$bootstrap | boolean | Whether the grid view will have Bootstrap table styling. | kartik\detail\DetailView |
$bordered | boolean | Whether the grid table will have a bordered style. |
kartik\detail\DetailView |
$bsColCssPrefixes | array | The bootstrap grid column css prefixes mapping, the key is the bootstrap versions, and the value is an array containing the sizes and their corresponding grid column css prefixes. | kartik\base\BootstrapTrait |
$bsCssMap | array | CSS conversion mappings across bootstrap library versions. | kartik\base\BootstrapTrait |
$bsExtBasename | integer | The yii2 bootstrap extension base name (readonly property available via getter method getBsExtBasename()) | kartik\base\BootstrapTrait |
$bsVer | integer | Bootstrap version number currently set (readonly property available via getter method getBsVer()) | kartik\base\BootstrapTrait |
$bsVersion | integer|string | The bootstrap library version that you wish to use for this specific extension / widget. | kartik\base\BootstrapTrait |
$buttonContainer | array | The options for the button toolbar container | kartik\detail\DetailView |
$buttons1 | string | The buttons to show when in view mode. | kartik\detail\DetailView |
$buttons2 | string | The buttons template to show when in edit mode. | kartik\detail\DetailView |
$childTableOptions | array | HTML attributes for the child table (applicable when using with multiple child columns). | kartik\detail\DetailView |
$condensed | boolean | Whether the grid table will have a condensed style. |
kartik\detail\DetailView |
$container | array | The HTML attributes for the widget container | kartik\detail\DetailView |
$counter | integer | A counter used to generate $id for widgets. | yii\base\Widget |
$defaultBtnCss | string | Default bootstrap button CSS (readonly property available via getter method getDefaultBtnCss()) | kartik\base\BootstrapTrait |
$defaultIconPrefix | string | Default icon prefix (readonly property available via getter method getDefaultIconPrefix()) | kartik\base\BootstrapTrait |
$defaultOptions | array | Default HTML attributes or other settings for widgets. | kartik\base\WidgetTrait |
$defaultPluginOptions | array | Default plugin options for the widget | kartik\base\WidgetTrait |
$deleteOptions | array | The HTML attributes for the edit button. | kartik\detail\DetailView |
$dropdownClass | string | Bootstrap dropdown class name based on currently configured bootstrap version (readonly property available via getter method getDropdownClass()) | kartik\base\BootstrapTrait |
$editAttributeContainer | array | The HTML attributes for the container displaying the EDIT mode attributes. | kartik\detail\DetailView |
$editButtonsContainer | array | The HTML attributes for the container displaying the EDIT mode buttons. | kartik\detail\DetailView |
$enableEditMode | boolean | Whether to enable edit mode for the detail view. | kartik\detail\DetailView |
$fadeDelay | integer | The fade animation delay in microseconds when toggling between the view and edit modes. | kartik\detail\DetailView |
$formClass | string | The form widget class name (extending from yii\widgets\ActiveForm) to be used for editing | kartik\detail\DetailView |
$formOptions | array | The options for the yii\widgets\ActiveForm instance that will be generated in edit mode based on $formClass. | kartik\detail\DetailView |
$formatter | array|yii\i18n\Formatter|null | The formatter used to format model attribute values into displayable texts. | yii\widgets\DetailView |
$hAlign | string | The horizontal alignment for the label column | kartik\detail\DetailView |
$hashVarLoadPosition | integer | The position where the client JS hash variables for the input widget will be loaded. | kartik\base\WidgetTrait |
$hideAlerts | boolean | Whether to hide all alerts. | kartik\detail\DetailView |
$hideIfEmpty | boolean | Whether to hide rows in view mode if value is null or empty. | kartik\detail\DetailView |
$hover | boolean | Whether the grid table will highlight row on hover . |
kartik\detail\DetailView |
$i18n | array | The the internalization configuration for this widget. | kartik\base\TranslationTrait |
$id | string|null | ID of the widget. Note that the type of this property differs in getter and setter. See getId() and setId() for details. | yii\base\Widget |
$krajeeDialogSettings | array | Configuration settings for the kartik\dialog\Dialog widget that will be used to render alerts and confirmation dialog prompts. | kartik\detail\DetailView |
$labelColOptions | array | The HTML attributes for the label column | kartik\detail\DetailView |
$mainTemplate | string | The main template to render the detail view. | kartik\detail\DetailView |
$mode | string | The mode for the Detail View when its initialized | kartik\detail\DetailView |
$model | array|object | The data model whose details are to be displayed. | yii\widgets\DetailView |
$moduleId | string | The module identifier if this widget is part of a module. | kartik\base\WidgetTrait |
$notSetIfEmpty | boolean | Whether to show values as not set if empty string | kartik\detail\DetailView |
$options | array | The HTML attributes for the detail view table | kartik\detail\DetailView |
$panel | array | The panel settings for displaying the grid view within a bootstrap styled panel. | kartik\detail\DetailView |
$panelCssPrefix | string | The CSS class prefix to apply to the bootstrap panel container (applicable when $panel is configured). | kartik\detail\DetailView |
$panelHeadingTemplate | string | The template for rendering the panel heading. | kartik\detail\DetailView |
$panelOptions | array | Bootstrap panel options. | kartik\detail\DetailView |
$panelTemplate | string | The template for rendering the grid within a bootstrap styled panel / card layout. | kartik\detail\DetailView |
$pjaxContainerId | string | The identifier for the PJAX widget container if the widget is to be rendered inside a PJAX container. | kartik\base\WidgetTrait |
$pjaxDuplicationFix | boolean | Prevent duplication of pjax containers when browser back & forward buttons are pressed. | kartik\base\WidgetTrait |
$pluginDestroyJs | string | The javascript that will be used to destroy the jQuery plugin | kartik\base\WidgetTrait |
$pluginEvents | array | Widget JQuery events. | kartik\base\WidgetTrait |
$pluginName | string | The plugin name | kartik\base\WidgetTrait |
$pluginOptions | array | Widget plugin options. | kartik\base\WidgetTrait |
$resetOptions | array | The HTML attributes for the reset button. | kartik\detail\DetailView |
$responsive | boolean | Whether the grid table will have a responsive style. |
kartik\detail\DetailView |
$rowOptions | array | The HTML attributes for each attribute row | kartik\detail\DetailView |
$saveOptions | array | The HTML attributes for the save button. | kartik\detail\DetailView |
$showErrorSummary | boolean | Whether to show form error summary as part of the error alert. | kartik\detail\DetailView |
$sourcePath | string | Directory path to the original widget source. | kartik\base\WidgetTrait |
$stack | yii\base\Widget[] | The widgets that are currently being rendered (not ended). | yii\base\Widget |
$striped | boolean | Whether the grid table will have a striped style. |
kartik\detail\DetailView |
$tableContainer | array | The HTML attributes for the table container | kartik\detail\DetailView |
$template | string|callable | The template used to render a single attribute. | yii\widgets\DetailView |
$tooltips | boolean | Whether to display bootstrap style tooltips for titles on hover of buttons. | kartik\detail\DetailView |
$updateOptions | array | The HTML attributes for the update button. | kartik\detail\DetailView |
$vAlign | string | The vertical alignment for the label column | kartik\detail\DetailView |
$valueColOptions | array | The HTML attributes for the value column | kartik\detail\DetailView |
$view | yii\web\View | The view object that can be used to render views or view files. Note that the type of this property differs in getter and setter. See getView() and setView() for details. | yii\base\Widget |
$viewAttributeContainer | array | The HTML attributes for the container displaying the VIEW mode attributes. | kartik\detail\DetailView |
$viewButtonsContainer | array | The HTML attributes for the container displaying the VIEW mode buttons. | kartik\detail\DetailView |
$viewOptions | array | The HTML attributes for the view button. | kartik\detail\DetailView |
$viewPath | string | The directory containing the view files for this widget. | yii\base\Widget |
Protected Properties
Property | Type | Description | Defined By |
---|---|---|---|
$_bsVer | integer | Current bootstrap version number | kartik\base\BootstrapTrait |
$_dataVar | string | The HTML5 data variable name that will be used to store the Json encoded pluginOptions within the element on which the jQuery plugin will be initialized. | kartik\base\WidgetTrait |
$_defaultBtnCss | string | Default bootstrap button CSS | kartik\base\BootstrapTrait |
$_defaultIconPrefix | string | Default icon CSS prefix | kartik\base\BootstrapTrait |
$_dropDownInputs | string[] | List of form inputs (dropdown based) | kartik\detail\DetailView |
$_encOptions | string | The JSON encoded plugin options. | kartik\base\WidgetTrait |
$_form | yii\widgets\ActiveForm | The active form instance | kartik\detail\DetailView |
$_hashVar | string | The generated hashed variable name that will store the JSON encoded pluginOptions in yii\web\View::POS_HEAD. | kartik\base\WidgetTrait |
$_inputsList | string[] | List of form inputs (non dropdown based) | kartik\detail\DetailView |
$_isBs4 | boolean | Flag to detect whether bootstrap 4. | kartik\base\BootstrapTrait |
$_msgCat | string | Translation message file category name for i18n. | kartik\base\TranslationTrait |
$_rowOptions | array | Internally processed HTML attributes for each table row. | kartik\detail\DetailView |
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of a component property. | yii\base\Component |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component |
__set() | Sets the value of a component property. | yii\base\Component |
__unset() | Sets a component property to be null. | yii\base\Component |
addCssClass() | Adds bootstrap CSS class to options by parsing the bootstrap version for the specified Bootstrap CSS type. | kartik\base\BootstrapTrait |
afterRun() | This method is invoked right after a widget is executed. | yii\base\Widget |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
beforeRun() | This method is invoked right before the widget is executed. | yii\base\Widget |
begin() | Begins a widget. | yii\base\Widget |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
end() | Ends a widget. | yii\base\Widget |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBSClass() | Gets the respective Bootstrap class based on currently configured bootstrap version. | kartik\base\BootstrapTrait |
getBaseSourcePath() | Get parsed base source path based on $sourcePath setting. If $sourcePath is not set, it will return the current working directory of this widget class. | kartik\base\WidgetTrait |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getBsVer() | Gets the current set bootstrap version number. | kartik\base\BootstrapTrait |
getCssClass() | Gets bootstrap css class by parsing the bootstrap version for the specified BS CSS type. | kartik\base\BootstrapTrait |
getDefaultBtnCss() | Gets the default button CSS | kartik\base\BootstrapTrait |
getDefaultIconPrefix() | Gets the default icon css prefix | kartik\base\BootstrapTrait |
getDropdownClass() | Gets the respective bootstrap dropdown class name based on currently configured bootstrap version. | kartik\base\BootstrapTrait |
getId() | Returns the ID of the widget. | yii\base\Widget |
getView() | kartik\base\WidgetTrait | |
getViewPath() | Returns the directory containing the view files for this widget. | yii\base\Widget |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
init() | Initializes the detail view. | kartik\detail\DetailView |
initI18N() | Yii i18n messages configuration for generating translations | kartik\base\TranslationTrait |
isBs() | Validate Bootstrap version | kartik\base\BootstrapTrait |
isBs4() | Validate if Bootstrap 4.x version. | kartik\base\BootstrapTrait |
off() | Detaches an existing event handler from this component. | yii\base\Component |
on() | Attaches an event handler to an event. | yii\base\Component |
registerWidgetJs() | Registers a JS code block for the widget. | kartik\base\WidgetTrait |
removeCssClass() | Removes bootstrap CSS class from options by parsing the bootstrap version for the specified Bootstrap CSS type. | kartik\base\BootstrapTrait |
render() | Renders a view. | yii\base\Widget |
renderFile() | Renders a view file. | yii\base\Widget |
run() | Renders the detail view. | kartik\detail\DetailView |
setId() | Sets the ID of the widget. | yii\base\Widget |
setView() | Sets the view object to be used by this widget. | yii\base\Widget |
trigger() | Triggers an event. | yii\base\Component |
widget() | Creates a widget instance and runs it. | yii\base\Widget |
Protected Methods
Method | Description | Defined By |
---|---|---|
addAsset() | Adds an asset to the view. | kartik\base\WidgetTrait |
configureBsVersion() | Configures the bootstrap version settings | kartik\base\BootstrapTrait |
fixPjaxDuplication() | Fix for weird PJAX container duplication behavior on pressing browser back and forward buttons. | kartik\base\WidgetTrait |
getBsExtBasename() | The yii2-bootstrap extension base name. | kartik\base\BootstrapTrait |
getDefaultButton() | Gets the default button. | kartik\detail\DetailView |
getPluginScript() | Returns the plugin registration script. | kartik\base\WidgetTrait |
hasEditErrors() | Check if model has editing errors. | kartik\detail\DetailView |
hasGridCol() | Checks if a bootstrap grid column class has been added to the container. | kartik\detail\DetailView |
hashPluginOptions() | Generates a hashed variable to store the pluginOptions. | kartik\base\WidgetTrait |
initBsVersion() | Initializes bootstrap versions for the widgets and asset bundles. | kartik\base\BootstrapTrait |
initCss() | Sets a default css class within options if not set. |
kartik\detail\DetailView |
initDestroyJs() | Generates the pluginDestroyJs script if it is not set. |
kartik\base\WidgetTrait |
initWidget() | Initializes the detail view widget | kartik\detail\DetailView |
isSameVersion() | Compares two versions and checks if they are of the same major BS version. | kartik\base\BootstrapTrait |
mergeDefaultOptions() | Merge default options | kartik\base\WidgetTrait |
normalizeAttributes() | Normalizes the attribute specifications. | kartik\detail\DetailView |
parseAttributeItem() | Parses and returns the attribute. | kartik\detail\DetailView |
parseAttributeProp() | Parses the attribute configuration and validates if a property is configured as a Closure callback. If so, the callback is executed and the attribute property is set to this callback output. | kartik\detail\DetailView |
parseVer() | Parses and returns the major BS version | kartik\base\BootstrapTrait |
registerAssets() | Register client assets for the kartik\detail\DetailView widget. | kartik\detail\DetailView |
registerPlugin() | Registers a specific plugin and the related events | kartik\base\WidgetTrait |
registerPluginOptions() | Registers plugin options by storing within a uniquely generated javascript variable. | kartik\base\WidgetTrait |
renderAlertBlock() | Initializes and renders alert container block. | kartik\detail\DetailView |
renderAttribute() | Renders a single attribute. | yii\widgets\DetailView |
renderAttributeItem() | Renders a single attribute item combination. | kartik\detail\DetailView |
renderAttributeRow() | Renders a single attribute. | kartik\detail\DetailView |
renderButton() | Renders a button. | kartik\detail\DetailView |
renderButtons() | Renders the buttons for a specific mode. | kartik\detail\DetailView |
renderDetailView() | Renders the main detail view widget. | kartik\detail\DetailView |
renderFormAttribute() | Renders each form attribute. | kartik\detail\DetailView |
renderPanel() | Sets the grid panel layout based on the $template and $panel settings. | kartik\detail\DetailView |
runWidget() | Prepares and runs the detail view widget. | kartik\detail\DetailView |
setDataVar() | Sets a HTML5 data variable. | kartik\base\WidgetTrait |
validateDisplay() | Validates the display of correct attributes and buttons at initialization based on mode. | kartik\detail\DetailView |
Events
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_RUN | yii\base\WidgetEvent | An event raised right after executing a widget. (available since version 2.0.11) | yii\base\Widget |
EVENT_BEFORE_RUN | yii\base\WidgetEvent | An event raised right before executing a widget. (available since version 2.0.11) | yii\base\Widget |
EVENT_INIT | yii\base\Event | An event that is triggered when the widget is initialized via init(). (available since version 2.0.11) | yii\base\Widget |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
ALIGN_BOTTOM | 'bottom' | Vertical bottom alignment for grid cells | kartik\detail\DetailView |
ALIGN_CENTER | 'center' | Horizontal center alignment for grid cells | kartik\detail\DetailView |
ALIGN_LEFT | 'left' | Horizontal left alignment for grid cells | kartik\detail\DetailView |
ALIGN_MIDDLE | 'middle' | Vertical middle alignment for grid cells | kartik\detail\DetailView |
ALIGN_RIGHT | 'right' | Horizontal right alignment for grid cells | kartik\detail\DetailView |
ALIGN_TOP | 'top' | Vertical top alignment for grid cells | kartik\detail\DetailView |
INPUT_CHECKBOX | 'checkbox' | Checkbox input | kartik\detail\DetailView |
INPUT_CHECKBOX_BUTTON_GROUP | 'checkboxButtonGroup' | Bootstrap styled checkbox button group | kartik\detail\DetailView |
INPUT_CHECKBOX_LIST | 'checkboxList' | Checkbox inputs as a list allowing multiple selection | kartik\detail\DetailView |
INPUT_CHECKBOX_X | '\kartik\checkbox\CheckboxX' | Krajee checkbox extended input widget kartik\checkbox\CheckboxX | kartik\detail\DetailView |
INPUT_COLOR | '\kartik\color\ColorInput' | Krajee color input widget kartik\color\ColorInput | kartik\detail\DetailView |
INPUT_DATE | '\kartik\date\DatePicker' | Krajee date picker input widget kartik\date\DatePicker | kartik\detail\DetailView |
INPUT_DATETIME | '\kartik\datetime\DateTimePicker' | Krajee date time Picker input widget kartik\datetime\DateTimePicker | kartik\detail\DetailView |
INPUT_DATE_RANGE | '\kartik\daterange\DateRangePicker' | Krajee date range picker input widget kartik\daterange\DateRangePicker | kartik\detail\DetailView |
INPUT_DEPDROP | '\kartik\depdrop\DepDrop' | Krajee dependent dropdown input widget kartik\depdrop\DepDrop | kartik\detail\DetailView |
INPUT_DROPDOWN_LIST | 'dropDownList' | Dropdown list allowing single select | kartik\detail\DetailView |
INPUT_FILE | 'fileInput' | File input | kartik\detail\DetailView |
INPUT_FILEINPUT | '\kartik\file\FileInput' | Krajee file input widget kartik\file\FileInput | kartik\detail\DetailView |
INPUT_HIDDEN | 'hiddenInput' | Hidden input. | kartik\detail\DetailView |
INPUT_HIDDEN_STATIC | 'hiddenStaticInput' | Hidden static input | kartik\detail\DetailView |
INPUT_HTML5 | 'input' | Other HTML5 input (e.g. color, range, email etc.) | kartik\detail\DetailView |
INPUT_LIST_BOX | 'listBox' | List box allowing multiple select | kartik\detail\DetailView |
INPUT_MONEY | '\kartik\money\MaskMoney' | Krajee mask money input widget kartik\money\MaskMoney | kartik\detail\DetailView |
INPUT_MULTISELECT | 'multiselect' | Krajee styled multiselect input that allows formatted checkbox list and radio list | kartik\detail\DetailView |
INPUT_PASSWORD | 'passwordInput' | Password input | kartik\detail\DetailView |
INPUT_RADIO | 'radio' | Radio input | kartik\detail\DetailView |
INPUT_RADIO_BUTTON_GROUP | 'radioButtonGroup' | Bootstrap styled radio button group | kartik\detail\DetailView |
INPUT_RADIO_LIST | 'radioList' | Radio inputs as a list | kartik\detail\DetailView |
INPUT_RANGE | '\kartik\range\RangeInput' | Krajee range input widget kartik\range\RangeInput | kartik\detail\DetailView |
INPUT_RATING | '\kartik\rating\StarRating' | Krajee star rating input widget kartik\rating\StarRating | kartik\detail\DetailView |
INPUT_SELECT2 | '\kartik\select2\Select2' | Krajee select2 input widget kartik\select2\Select2 | kartik\detail\DetailView |
INPUT_SLIDER | '\kartik\slider\Slider' | Krajee slider input widget kartik\slider\Slider | kartik\detail\DetailView |
INPUT_SORTABLE | '\kartik\sortinput\SortableInput' | Krajee sortable input widget kartik\sortinput\SortableInput | kartik\detail\DetailView |
INPUT_SPIN | '\kartik\touchspin\TouchSpin' | Krajee touch spin input widget kartik\touchspin\TouchSpin | kartik\detail\DetailView |
INPUT_STATIC | 'staticInput' | Static input (styled using bootstrap style) | kartik\detail\DetailView |
INPUT_SWITCH | '\kartik\switchinput\SwitchInput' | Krajee switch input widget kartik\switchinput\SwitchInput | kartik\detail\DetailView |
INPUT_TEXT | 'textInput' | Text input | kartik\detail\DetailView |
INPUT_TEXTAREA | 'textarea' | Text area | kartik\detail\DetailView |
INPUT_TIME | '\kartik\time\TimePicker' | Krajee Time picker input widget kartik\time\TimePicker | kartik\detail\DetailView |
INPUT_TYPEAHEAD | '\kartik\typeahead\Typeahead' | Krajee typeahead input widget kartik\typeahead\Typeahead | kartik\detail\DetailView |
INPUT_WIDGET | 'widget' | Input widget | kartik\detail\DetailView |
MODE_EDIT | 'edit' | Edit mode for the detail view | kartik\detail\DetailView |
MODE_VIEW | 'view' | View mode for the detail view | kartik\detail\DetailView |
TYPE_ACTIVE | 'active' | The active bootstrap contextual color type (applicable only for table row contextual style) | kartik\detail\DetailView |
TYPE_DANGER | 'danger' | The danger bootstrap contextual color type | kartik\detail\DetailView |
TYPE_DARK | 'dark' | The dark bootstrap contextual color type (applicable only for panel contextual style) | kartik\detail\DetailView |
TYPE_DEFAULT | 'default' | The default bootstrap contextual color type (applicable only for panel contextual style) | kartik\detail\DetailView |
TYPE_INFO | 'info' | The information bootstrap contextual color type | kartik\detail\DetailView |
TYPE_LIGHT | 'light' | The light bootstrap contextual color type (applicable only for panel contextual style) | kartik\detail\DetailView |
TYPE_PRIMARY | 'primary' | The primary bootstrap contextual color type | kartik\detail\DetailView |
TYPE_SECONDARY | 'secondary' | The secondary bootstrap contextual color type | kartik\detail\DetailView |
TYPE_SUCCESS | 'success' | The success bootstrap contextual color type | kartik\detail\DetailView |
TYPE_WARNING | 'warning' | The warning bootstrap contextual color type | kartik\detail\DetailView |
Property Details
List of form inputs (dropdown based)
self::INPUT_LIST_BOX => 'listBox',
self::INPUT_DROPDOWN_LIST => 'dropDownList',
self::INPUT_CHECKBOX_LIST => 'checkboxList',
self::INPUT_RADIO_LIST => 'radioList',
self::INPUT_CHECKBOX_BUTTON_GROUP => 'checkboxButtonGroup',
self::INPUT_RADIO_BUTTON_GROUP => 'radioButtonGroup'
]
The active form instance
List of form inputs (non dropdown based)
self::INPUT_HIDDEN => 'hiddenInput',
self::INPUT_TEXT => 'textInput',
self::INPUT_PASSWORD => 'passwordInput',
self::INPUT_TEXTAREA => 'textarea',
self::INPUT_CHECKBOX => 'checkbox',
self::INPUT_RADIO => 'radio',
self::INPUT_LIST_BOX => 'listBox',
self::INPUT_DROPDOWN_LIST => 'dropDownList',
self::INPUT_CHECKBOX_LIST => 'checkboxList',
self::INPUT_RADIO_LIST => 'radioList',
self::INPUT_HTML5 => 'input',
self::INPUT_FILE => 'fileInput',
self::INPUT_WIDGET => 'widget',
self::INPUT_CHECKBOX_BUTTON_GROUP => 'checkboxButtonGroup',
self::INPUT_RADIO_BUTTON_GROUP => 'radioButtonGroup'
]
Internally processed HTML attributes for each table row. Defaults settings from $rowOptions.
The HTML attributes for the alert block container which will display any alert messages received on update or delete of record. This will not be displayed if there are no alert messages.
The alert flash message settings.
This will be set as $key => $value
, pairs where:
$key
: string, flash message key e.g.error
,success
.$value
: string|array, of CSS classes for the flash message e.g.['alert', 'alert-danger']
. This defaults to the following setting:
[
'kv-detail-error' => ['alert', 'alert-danger'],
'kv-detail-success' => ['alert', 'alert-success'],
'kv-detail-info' => ['alert', 'alert-info'],
'kv-detail-warning' => ['alert', 'alert-warning'],
]
The widget settings for each bootstrap alert displayed in the alert container block.
The CSS class in options
within this property will be auto derived and appended.
- For
update
, the error messages will be displayed, only if you have set messages usingYii::$app->session->setFlash
. The CSS class for the error block will be auto-derived based on flash message type usingalertMessageSettings
. - For
delete
, the error messages will be displayed based on the ajax response. The ajax response should be an object that contain the following settings:success
: boolean, whether the ajax delete is successful.messages
: array|object,the list of messages to display as key value pairs. The key must be one of the message keys in thealertMessageSettings
, and the value must be the message content to be displayed.
Whether to convert array values to string using print_r
.
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 "attribute", "attribute:format" or "attribute:format:label", where "attribute" refers to the attribute name, and "format" represents the format of the attribute. The "format" is passed to the yii\i18n\Formatter::format() method to format an attribute value into a displayable text. Please refer to yii\i18n\Formatter for the supported types. Both "format" and "label" are optional. They will take default values if absent.
An attribute can also be specified in terms of an array with the following elements.
attribute
: string|Closure, the attribute name. This is required if either "label" or "value" is not specified.label
: string|Closure, the label associated with the attribute. If this is not specified, it will be generated from the attribute name.value
: mixed|Closure, the value to be displayed. If this is not specified, it will be retrieved from $model using the attribute name by calling yii\helpers\ArrayHelper::getValue(). Note that this value will be formatted into a displayable text according to the "format" option.format
: mixed|Closure, the type of the value that determines how the value would be formatted into a displayable text. Please refer to yii\i18n\Formatter for supported types.visible
: boolean|Closure, whether the attribute is visible. If set tofalse
, the attribute will NOT be displayed.
Additional special settings are:
viewModel
: Model|Closure, the model to be used for this attribute in VIEW mode. This will override themodel
setting at the widget level. If not set, the widgetmodel
setting will be used.editModel
: Model|Closure, the model to be used for this attribute in EDIT mode. This will override themodel
setting at the widget level. If not set, the widgetmodel
setting will be used.rowOptions
: array|Closure, HTML attributes for the row (if not set, this will be defaulted to therowOptions
set at the widget level)labelColOptions
: array|Closure, HTML attributes for the label column (if not set, this will be defaulted to thelabelColOptions
set at the widget level)valueColOptions
: array|Closure, HTML attributes for the value column (if not set, this will be defaulted tovalueColOptions
set at the widget level)group
: boolean|Closure, whether to group the selection by merging the label and value into a single column.groupOptions
: array|Closure, HTML attributes for the grouped/merged column whengroup
is set totrue
.type
: string|Closure, the input type for rendering the attribute in edit mode. Must be one of theINPUT_
constants.displayOnly
: boolean|Closure, if the input is to be set to asdisplay only
in edit mode.- widgetOptions: array|Closure_, the widget options if you set
type
to INPUT_WIDGET. The following special options are recognized:class
: _string the fully namespaced widget class.
items
: array|Closure, the list of data items for dropDownList, listBox, checkboxList & radioListinputType
: string|Closure, the HTML 5 input type iftype
is set to INPUT_HTML5.inputContainer
: array|Closure, HTML attributes for the input containerinputWidth
: string|Closure, the width of the container holding the input, should be appended along with the width unit (px
or%
) - this property is deprecated since v1.7.7fieldConfig
: array|Closure, optional, the Active field configuration.options
: array|Closure, optional, the HTML attributes for the input.updateAttr
: string|Closure, optional, the name of the attribute to be updated, when in edit mode. This will default to theattribute
setting.updateMarkup
: string|Closure, the raw markup to render in edit mode. If not set, this normally will be automatically generated based onattribute
orupdateAttr
setting. If this is set it will override the default markup.
Note that all of the attribute properties above can also be setup as a Closure callback with the signature
function($form, $widget)
, where:
$form
: ActiveForm, is the current active form object in the detail view.$widget
: DetailView, is the current detail view widget instance.
Whether the grid view will have Bootstrap table styling.
Whether the grid table will have a bordered
style. Applicable only if $bootstrap is true
.
The options for the button toolbar container
The buttons to show when in view mode. The following tokens will be parsed and replaced:
{view}
: the view button{update}
: the update button{delete}
: the delete button{save}
: the save button
The buttons template to show when in edit mode. The following tokens will be parsed and replaced:
{view}
: the view button{update}
: the update button{reset}
: the reset button{delete}
: the delete button{save}
: the save button
HTML attributes for the child table (applicable when using with multiple child columns).
Whether the grid table will have a condensed
style. Applicable only if $bootstrap is true
.
The HTML attributes for the widget container
The HTML attributes for the edit button. The following special options are recognized:
label
: string, the delete button label. This will not be HTML encoded.- Defaults to
<i class="fas fa-trash-alt"></i>
for Bootstrap 4.x & Bootstrap 5.x. - Defaults to
<i class="glyphicon glyphicon-trash"></i>
for Bootstrap 3.x.
- Defaults to
url
: string, the delete button url. Defaults to#
.params
: array, the parameters to the delete action and their values to be passed via ajax which you must set as key value pairs. This will be automatically json string encoded, so to escape javascript variables & methods you can use yii\web\JsExpressionajaxSettings
: array, the ajax settings if you choose to override the delete ajax settings.confirm
: string, the confirmation message before triggering delete. Defaults toAre you sure you want to delete this item?
(will be translated for your locale language set).showErrorStack
: boolean, whether to show the complete error stack. Defaults tofalse
.
The HTML attributes for the container displaying the EDIT mode attributes.
The HTML attributes for the container displaying the EDIT mode buttons.
Whether to enable edit mode for the detail view.
The fade animation delay in microseconds when toggling between the view and edit modes.
The form widget class name (extending from yii\widgets\ActiveForm) to be used for editing
The options for the yii\widgets\ActiveForm instance that will be generated in edit mode based on $formClass.
The horizontal alignment for the label column
Whether to hide all alerts. Defaults to false
.
Whether to hide rows in view mode if value is null or empty.
Whether the grid table will highlight row on hover
. Applicable only if $bootstrap is true
.
Configuration settings for the kartik\dialog\Dialog widget that will be used to render alerts and confirmation dialog prompts.
See also http://demos.krajee.com/dialog.
The HTML attributes for the label column
The main template to render the detail view. The following tokens will be parsed and replaced:
The mode for the Detail View when its initialized
Whether to show values as not set if empty string
The HTML attributes for the detail view table
The panel settings for displaying the grid view within a bootstrap styled panel. This property is
therefore applicable only if $bootstrap property is true
. The following array keys can be configured:
type
: string, the panel contextual type. Set it to one of the TYPE constants. If not set, will default to TYPE_DEFAULT.options
: array, the HTML attributes for the panel container. If theclass
is not set, it will be auto derived using the paneltype
and $panelCssPrefix specific to the configured bootstrap version.heading
: string|boolean, the panel heading. If set tofalse
, will not be displayed.headingOptions
: array, HTML attributes for the panel heading container. Defaults to:['class'=>'card-heading {COLOR}']
for Bootstrap 4.x & Bootstrap 5.x. The {COLOR} token will be auto calculated and replaced based on thetype
setting.['class'=>'panel-heading']
for Bootstrap 3.x.
titleOptions
: array, HTML attributes for the panel title container. The following tags are specially parsed:tag
: string, the HTML tag to render the title. Defaults to:span
for Bootstrap 4.x & Bootstrap 5.x.h3
for Bootstrap 3.x.
The
titleOptions
defaults to:[]
for Bootstrap 4.x & Bootstrap 5.x.['class'=>'panel-title']
for Bootstrap 3.x.
footer
: string|boolean, the panel footer. If set tofalse
will not be displayed.footerOptions
: array, HTML attributes for the panel footer container. Defaults to:['class'=>'card-footer']
for Bootstrap 4.x & Bootstrap 5.x.['class'=>'panel-footer']
for Bootstrap 3.x.
before
: string|boolean, content to be placed before/above the grid (after the header). To not display this section, set this tofalse
.beforeOptions
: array, HTML attributes for thebefore
text. If theclass
is not set, it will default tokv-panel-before
.after
: string|boolean, any content to be placed after/below the grid (before the footer). To not display this section, set this tofalse
.afterOptions
: array, HTML attributes for theafter
text. If theclass
is not set, it will default tokv-panel-after
.
The CSS class prefix to apply to the bootstrap panel container (applicable when $panel is configured).
The template for rendering the panel heading. The following special tokens are recognized and will be replaced:
DetailView::panel['options']
instead.
Bootstrap panel options.
The template for rendering the grid within a bootstrap styled panel / card layout. The following special tokens are recognized and will be replaced:
{prefix}
: the CSS prefix name as set in $panelCssPrefix.{type}
: the panel type that will append the bootstrap contextual CSS.{panelHeading}
: the panel heading content.{panelBefore}
: the content before panel.{panelAfter}
: the content after panel.{panelFooter}
: the panel footer content.{items}
: the detail view items.{buttons}
: buttons to be displayed as set in $buttons1 or $buttons2.{title}
: the panel heading title content.
The HTML attributes for the reset button. This button will reset the form in edit mode. The following special options are recognized:
label
: string, the reset button label. This will not be HTML encoded.- Defaults to
<i class="fas fa-ban"></i>
for Bootstrap 4.x & Bootstrap 5.x. - Defaults to
<i class="glyphicon glyphicon-ban-circle"></i>
for Bootstrap 3.x.
- Defaults to
Whether the grid table will have a responsive
style. Applicable only if $bootstrap is true
.
The HTML attributes for each attribute row
The HTML attributes for the save button. This will default to a form submit button. The following special options are recognized:
label
: string, the save button label. This will not be HTML encoded. Defaults to:<i class="fas fa-save"></i>
for Bootstrap 4.x & Bootstrap 5.x.<i class="glyphicon glyphicon-floppy-disk"></i>
for Bootstrap 3.x.
Whether to show form error summary as part of the error alert. Defaults to false
.
Whether the grid table will have a striped
style. Applicable only if $bootstrap is true
.
The HTML attributes for the table container
Whether to display bootstrap style tooltips for titles on hover of buttons.
The HTML attributes for the update button. This button will toggle the edit mode on. The following special options are recognized:
label
: the update button label. This will not be HTML encoded.- Defaults to
<i class="fas fa-pencil-alt"></i>
for Bootstrap 4.x & Bootstrap 5.x. - Defaults to
<i class="glyphicon glyphicon-pencil"></i>
for Bootstrap 3.x.
- Defaults to
The vertical alignment for the label column
The HTML attributes for the value column
The HTML attributes for the container displaying the VIEW mode attributes.
The HTML attributes for the container displaying the VIEW mode buttons.
The HTML attributes for the view button. This will toggle the view from edit mode to view mode. The following special options are recognized:
label
: the save button label. This will not be HTML encoded.- Defaults to
<i class="fas fa-eye"></i>
for Bootstrap 4.x & Bootstrap 5.x. - Defaults to
<i class="glyphicon glyphicon-eye-open"></i>
for Bootstrap 3.x.
- Defaults to
Method Details
Gets the default button.
protected string getDefaultButton ( $type, $iconBs3, $iconNotBs3, $title ) | ||
$type | string | The button type |
$iconBs3 | string | The bootstrap 3 icon suffix name |
$iconNotBs3 | string | The non bootstrap 3 icon suffix name |
$title | string | The title to display on hover |
throws | \yii\base\InvalidConfigException|\Exception |
---|
Check if model has editing errors.
protected boolean hasEditErrors ( ) |
Checks if a bootstrap grid column class has been added to the container.
protected static boolean hasGridCol ( $container = [] ) | ||
$container | array | |
throws | Exception |
---|
Initializes the detail view.
This method will initialize required property values.
public void init ( ) | ||
throws | yii\base\InvalidConfigException |
---|
Sets a default css class within options
if not set.
protected static void initCss ( &$options, $css ) | ||
$options | array | The HTML options |
$css | string|array | The CSS class to test and append |
Initializes the detail view widget
protected void initWidget ( ) | ||
throws | yii\base\InvalidConfigException |
---|
Normalizes the attribute specifications.
protected void normalizeAttributes ( ) | ||
throws | yii\base\InvalidConfigException |
---|
Parses and returns the attribute.
protected array parseAttributeItem ( $attribute ) | ||
$attribute | string|array | The attribute item configuration |
return | array | The parsed attribute item configuration |
---|---|---|
throws | yii\base\InvalidConfigException |
Parses the attribute configuration and validates if a property is configured as a Closure callback. If so, the callback is executed and the attribute property is set to this callback output.
The signature of the callback is function($form, $widget)
, where:
$form
: yii\widgets\ActiveForm, is the current active form object in the detail view.$widget
: kartik\detail\DetailView, is the current detail view widget instance.
protected mixed parseAttributeProp ( $setting ) | ||
$setting | mixed | Is the attribute property setting |
return | mixed | The parsed attribute setting |
---|
Register client assets for the kartik\detail\DetailView widget.
protected void registerAssets ( ) | ||
throws | Exception |
---|
Initializes and renders alert container block.
protected void renderAlertBlock ( ) | ||
throws | Exception |
---|
Renders a single attribute item combination.
protected string renderAttributeItem ( $attribute ) | ||
$attribute | array | The specification of the attribute to be rendered. |
return | string | The rendering result |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders a single attribute.
protected string renderAttributeRow ( $attribute ) | ||
$attribute | array | The specification of the attribute to be rendered. |
return | string | The rendering result |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders a button.
protected string renderButton ( $type ) | ||
$type | string | The button type |
throws | yii\base\InvalidConfigException |
---|
Renders the buttons for a specific mode.
protected string renderButtons ( $mode = 1 ) | ||
$mode | integer | |
return | string | The buttons content |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders the main detail view widget.
protected string renderDetailView ( ) | ||
return | string | The detail view content |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders each form attribute.
protected mixed renderFormAttribute ( $config ) | ||
$config | array | The attribute config |
throws | yii\base\InvalidConfigException |
---|
protected string renderPanel ( $items ) | ||
$items | string | |
throws | \yii\base\InvalidConfigException|\Exception |
---|
Renders the detail view.
This is the main entry of the whole detail view rendering.
public void run ( ) | ||
throws | ReflectionException |
---|
Prepares and runs the detail view widget.
protected void runWidget ( ) | ||
throws | ReflectionException | |
---|---|---|
throws | Exception |
Validates the display of correct attributes and buttons at initialization based on mode.
protected void validateDisplay ( ) |