Trait kartik\base\WidgetTrait

Implemented bykartik\base\Html5Input, kartik\base\InputWidget, kartik\base\Widget, kartik\select2\Select2, kartik\tree\TreeView, kartik\tree\TreeViewInput
Available since version1.6.0

Trait used for Krajee widgets.

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
addAsset() Adds an asset to the view kartik\base\WidgetTrait
getPluginScript() Returns the plugin registration script kartik\base\WidgetTrait
hashPluginOptions() Generates a hashed variable to store the pluginOptions. The following special data attributes will also be setup for the input widget, that can be accessed through javascript : - 'data-krajee-{name}' will store the hashed variable storing the plugin options. The {name} tag will represent the plugin name (e.g. select2, typeahead etc.) - Fixes issue #6. kartik\base\WidgetTrait
registerPlugin() Registers a specific plugin and the related events kartik\base\WidgetTrait
registerPluginOptions() Registers plugin options by storing it in a hashed javascript variable kartik\base\WidgetTrait
setDataVar() Sets HTML5 data variable kartik\base\WidgetTrait

Method Details

addAsset() protected method

Adds an asset to the view

protected void addAsset ( $view, $file, $type, $class )
$view \yii\web\View

The View object

$file string

The asset file name

$type string

The asset file type (css or js)

$class string

The class name of the AssetBundle

getPluginScript() protected method

Returns the plugin registration script

protected \kartik\base\the getPluginScript ( $name, $element null, $callback null, $callbackCon null )
$name string

The name of the plugin

$element string

The plugin target element

$callback string

The javascript callback function to be called after plugin loads

$callbackCon string

The javascript callback function to be passed to the plugin constructor

return \kartik\base\the

Generated plugin script

hashPluginOptions() protected method

Generates a hashed variable to store the pluginOptions. The following special data attributes will also be setup for the input widget, that can be accessed through javascript : - 'data-krajee-{name}' will store the hashed variable storing the plugin options. The {name} tag will represent the plugin name (e.g. select2, typeahead etc.) - Fixes issue #6.

protected void hashPluginOptions ( $name )
$name string

The name of the plugin

registerPlugin() protected method

Registers a specific plugin and the related events

protected void registerPlugin ( $name, $element null, $callback null, $callbackCon null )
$name string

The name of the plugin

$element string

The plugin target element

$callback string

The javascript callback function to be called after plugin loads

$callbackCon string

The javascript callback function to be passed to the plugin constructor

registerPluginOptions() protected method

Registers plugin options by storing it in a hashed javascript variable

protected void registerPluginOptions ( $name )
$name
setDataVar() protected method

Sets HTML5 data variable

protected void setDataVar ( $name )
$name string

The plugin name