Class kartik\base\InputWidget

Inheritancekartik\base\InputWidget » yii\widgets\InputWidget
Uses Traitskartik\base\TranslationTrait, kartik\base\WidgetTrait
Subclasseskartik\base\Html5Input, kartik\select2\Select2
Available since version1.0

Base input widget class for Krajee extensions

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$convertFormat boolean Whether the widget should automatically format the date from the PHP DateTime format to the javascript/jquery plugin format kartik\base\InputWidget
$data array The data (for list inputs) kartik\base\InputWidget
$disabled boolean Whether input is to be disabled kartik\base\InputWidget
$i18n array The the internalization configuration for this widget kartik\base\InputWidget
$language string The language configuration (e.g. 'fr-FR', 'zh-CN'). kartik\base\InputWidget
$pluginEvents array Widget JQuery events. kartik\base\InputWidget
$pluginLoading mixed Show loading indicator while plugin loads kartik\base\InputWidget
$pluginName string The name of the jQuery plugin kartik\base\InputWidget
$pluginOptions array Widget plugin options kartik\base\InputWidget
$readonly boolean Whether input is to be readonly kartik\base\InputWidget

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_dataVar string The hashed variable to store the pluginOptions kartik\base\InputWidget
$_encOptions string The Json encoded options kartik\base\InputWidget
$_hashVar string The hashed variable to store the pluginOptions kartik\base\InputWidget
$_lang string The two or three letter lowercase code for the language according to ISO-639 kartik\base\InputWidget
$_langFile string The language js file kartik\base\InputWidget
$_loadIndicator string The indicator for loading kartik\base\InputWidget
$_msgCat string Translation message file category name for i18n kartik\base\InputWidget

Public Methods

Hide inherited methods

MethodDescriptionDefined By
init() kartik\base\InputWidget
initI18N() Yii i18n messages configuration for generating translations kartik\base\TranslationTrait

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
addAsset() Adds an asset to the view kartik\base\WidgetTrait
convertDateFormat() Automatically convert the date format from PHP DateTime to Javascript DateTime format kartik\base\InputWidget
getInput() Generates an input kartik\base\InputWidget
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
initDisability() Validates and sets disabled or readonly inputs kartik\base\InputWidget
initLanguage() Initialize the plugin language kartik\base\InputWidget
parseDateFormat() Parses date format based on attribute type using yii\helpers\FormatConverter Used only within DatePicker and DateTimePicker. kartik\base\InputWidget
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
setLanguage() Sets the language JS file if it exists kartik\base\InputWidget

Constants

Hide inherited constants

ConstantValueDescriptionDefined By
LOAD_PROGRESS '
 
'
kartik\base\InputWidget

Property Details

$_dataVar protected property

The hashed variable to store the pluginOptions

protected string $_dataVar null
$_encOptions protected property

The Json encoded options

protected string $_encOptions ''
$_hashVar protected property

The hashed variable to store the pluginOptions

protected string $_hashVar null
$_lang protected property

The two or three letter lowercase code for the language according to ISO-639

protected string $_lang ''
$_langFile protected property

The language js file

protected string $_langFile ''
$_loadIndicator protected property

The indicator for loading

protected string $_loadIndicator ''
$_msgCat protected property

Translation message file category name for i18n

protected string $_msgCat ''
$convertFormat public property

Whether the widget should automatically format the date from the PHP DateTime format to the javascript/jquery plugin format

See also http://php.net/manual/en/function.date.php.

public boolean $convertFormat false
$data public property

The data (for list inputs)

public array $data = []
$disabled public property

Whether input is to be disabled

public boolean $disabled false
$i18n public property

The the internalization configuration for this widget

public array $i18n = []
$language public property

The language configuration (e.g. 'fr-FR', 'zh-CN'). The format for the language/locale is ll-CC where ll is a two or three letter lowercase code for a language according to ISO-639 and CC is the country code according to ISO-3166. If this property not set, then the current application language will be used.

public string $language null
$pluginEvents public property

Widget JQuery events. You must define events in event-name => event-function format for example: ~~~ pluginEvents = [

   "change" => "function() { log("change"); }",
   "open" => "function() { log("open"); }",

]; ~~~

public array $pluginEvents = []
$pluginLoading public property

Show loading indicator while plugin loads

public mixed $pluginLoading true
$pluginName public property

The name of the jQuery plugin

public string $pluginName ''
$pluginOptions public property

Widget plugin options

public array $pluginOptions = []
$readonly public property

Whether input is to be readonly

public boolean $readonly false

Method Details

convertDateFormat() protected static method

Automatically convert the date format from PHP DateTime to Javascript DateTime format

See also:

protected static string convertDateFormat ( $format )
$format string

The PHP date format string

getInput() protected method

Generates an input

protected void getInput ( $type, $list false )
$type
$list
init() public method

public void init ( )
initDisability() protected method

Validates and sets disabled or readonly inputs

protected void initDisability ( <b>&</b>$options )
$options array

The HTML attributes for the input

initLanguage() protected method

Initialize the plugin language

protected void initLanguage ( $property 'language', $full false )
$property string

The name of language property in $pluginOptions.

$full boolean

Whether to use the full language string. Defaults to false which is the 2 (or 3) digit ISO-639 format. Defaults to 'language'.

parseDateFormat() protected method

Parses date format based on attribute type using yii\helpers\FormatConverter Used only within DatePicker and DateTimePicker.

protected mixed|string parseDateFormat ( $type )
$type string

The attribute type whether date, datetime, or time

throws \kartik\base\InvalidConfigException
setLanguage() protected method

Sets the language JS file if it exists

protected void setLanguage ( $prefix, $assetPath null, $filePath null, $suffix '.js' )
$prefix
$assetPath string

The path to the assets

$filePath string

The path to the JS file with the file name prefix

$suffix string

The file name suffix - defaults to '.js'