Class kartik\field\FieldRange

Inheritancekartik\field\FieldRange » kartik\base\Widget » yii\base\Widget » yii\base\Component » yii\base\BaseObject
Implementskartik\base\BootstrapInterface, yii\base\Configurable, yii\base\ViewContextInterface
Uses Traitskartik\base\BootstrapTrait, kartik\base\TranslationTrait, kartik\base\WidgetTrait
Available since version1.0

FieldRange widget enables to setup and manage an input field range (from/to values) that works seamlessly with kartik\form\ActiveForm and kartik\form\ActiveField.

The widget renders the range feature by implementing styling available with

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$addInputCss string The additional CSS class that will be appended to input markup kartik\field\FieldRange
$attribute1 string The first field's model attribute that this widget is associated with. kartik\field\FieldRange
$attribute2 string The second field's model attribute that this widget is associated with. kartik\field\FieldRange
$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
$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
$container array The HTML options for the main container kartik\field\FieldRange
$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
$dropdownClass string Bootstrap dropdown class name based on currently configured bootstrap version (readonly property available via getter method getDropdownClass()) kartik\base\BootstrapTrait
$errorContainer array The HTML attributes for the common error block container kartik\field\FieldRange
$fieldConfig1 array The active field configuration for attribute1 (applicable when $form property is set). kartik\field\FieldRange
$fieldConfig2 array The active field configuration for attribute2 (applicable when $form property is set) kartik\field\FieldRange
$form kartik\form\ActiveForm The form instance, if used with active form kartik\field\FieldRange
$hashVarLoadPosition integer The position where the client JS hash variables for the input widget will be loaded. kartik\base\WidgetTrait
$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
$items1 array The option data items for first field if $type is set to INPUT_DROPDOWN_LIST, INPUT_LIST_BOX, INPUT_CHECKBOX_LIST, INPUT_RADIO_LIST, INPUT_CHECKBOX_BUTTON_GROUP, INPUT_RADIO_BUTTON_GROUP. kartik\field\FieldRange
$items2 array The option data items for second fieldif $type is set to INPUT_DROPDOWN_LIST, INPUT_LIST_BOX, INPUT_CHECKBOX_LIST, INPUT_RADIO_LIST, INPUT_CHECKBOX_BUTTON_GROUP, INPUT_RADIO_BUTTON_GROUP. kartik\field\FieldRange
$label string The label to be displayed. kartik\field\FieldRange
$labelOptions array HTML attributes for the label. kartik\field\FieldRange
$model yii\base\Model The data model that this widget is associated with. kartik\field\FieldRange
$moduleId string The module identifier if this widget is part of a module. kartik\base\WidgetTrait
$name1 string The first field's input name. kartik\field\FieldRange
$name2 string The second field's input name. kartik\field\FieldRange
$options array The HTML attributes for the generated widget input. kartik\field\FieldRange
$options1 array The HTML attributes for the first field's input tag. kartik\field\FieldRange
$options2 array The HTML attributes for the second field's input tag. kartik\field\FieldRange
$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
$separator string The field separator string between first and second field kartik\field\FieldRange
$separatorOptions array HTML attributes for the separator. kartik\field\FieldRange
$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
$template string The template to render the widget. kartik\field\FieldRange
$type string The input types for the field (must be one of the kartik\field\FieldRange::INPUT_XXX constants. kartik\field\FieldRange
$useAddons boolean Whether to implement and render bootstrap 3 addons using kartik\form\ActiveField. kartik\field\FieldRange
$value1 string The first field's input value. kartik\field\FieldRange
$value2 string The second field's input value. kartik\field\FieldRange
$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
$viewPath string The directory containing the view files for this widget. yii\base\Widget
$widgetClass string The widget class to use if $type is set to INPUT_WIDGET. kartik\field\FieldRange
$widgetContainer array The HTML attributes for the widget container kartik\field\FieldRange
$widgetOptions1 array The widget options for the first field if $type is INPUT_WIDGET or one of the Krajee input inputs from \kartik\widgets. kartik\field\FieldRange
$widgetOptions2 array The widget options for the second field if $type is INPUT_WIDGET or one of the inputs from \kartik\widgets. kartik\field\FieldRange

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined 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
$_encOptions string The JSON encoded plugin options. kartik\base\WidgetTrait
$_hashVar string The generated hashed variable name that will store the JSON encoded pluginOptions in yii\web\View::POS_HEAD. kartik\base\WidgetTrait
$_isBs4 boolean Flag to detect whether bootstrap 4. kartik\base\BootstrapTrait
$_msgCat string Translation message file category name for i18n. kartik\base\TranslationTrait

Public Methods

Hide inherited methods

MethodDescriptionDefined 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 object. kartik\field\FieldRange
initI18N() Yii i18n messages configuration for generating translations kartik\base\TranslationTrait
initOptions() Initializes the widget options. kartik\field\FieldRange
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() Executes the widget. kartik\field\FieldRange
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
validateSettings() Validates the widget settings. kartik\field\FieldRange
widget() Creates a widget instance and runs it. yii\base\Widget

Protected Methods

Hide inherited methods

MethodDescriptionDefined 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
getDatePicker() Generate the range input markup for kartik\date\DatePicker widget. kartik\field\FieldRange
getFormInput() Generate the input markup for an kartik\form\ActiveForm input. kartik\field\FieldRange
getInput() Generate the input markup for a normal input. kartik\field\FieldRange
getPluginScript() Returns the plugin registration script. kartik\base\WidgetTrait
hasModel() Checks whether the current widget has a model assigned to it. kartik\field\FieldRange
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
initDestroyJs() Generates the pluginDestroyJs script if it is not set. kartik\base\WidgetTrait
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
parseVer() Parses and returns the major BS version kartik\base\BootstrapTrait
registerAssets() Registers client assets for kartik\field\FieldRange widget. kartik\field\FieldRange
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
renderWidget() Renders the field range widget. kartik\field\FieldRange
setDataVar() Sets a HTML5 data variable. kartik\base\WidgetTrait
setWidgetOptions() Sets widget options. kartik\field\FieldRange

Events

Hide inherited events

EventTypeDescriptionDefined 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

Hide inherited constants

ConstantValueDescriptionDefined By
INPUT_CHECKBOX 'checkbox' Input type rendered via kartik\helpers\Html::checkbox() kartik\field\FieldRange
INPUT_CHECKBOXX '\kartik\checkbox\CheckboxX' Krajee Checkbox Extended widget kartik\checkbox\CheckboxX kartik\field\FieldRange
INPUT_CHECKBOX_BUTTON_GROUP 'checkboxButtonGroup' Input type rendered via kartik\helpers\Html::checkboxButtonGroup() kartik\field\FieldRange
INPUT_CHECKBOX_LIST 'checkboxList' Input type rendered via kartik\helpers\Html::checkboxList() kartik\field\FieldRange
INPUT_COLOR '\kartik\color\ColorInput' Krajee ColorInput widget kartik\color\ColorInput kartik\field\FieldRange
INPUT_DATE '\kartik\date\DatePicker' Krajee DatePicker widget kartik\date\DatePicker kartik\field\FieldRange
INPUT_DATETIME '\kartik\datetime\DateTimePicker' Krajee DateTimePicker widget kartik\datetime\DateTimePicker kartik\field\FieldRange
INPUT_DEPDROP '\kartik\depdrop\DepDrop' Krajee Dependent Dropdown widget kartik\depdrop\DepDrop kartik\field\FieldRange
INPUT_DROPDOWN_LIST 'dropDownList' Input type rendered via kartik\helpers\Html::dropDownList() kartik\field\FieldRange
INPUT_FILE 'fileInput' Input type rendered via kartik\helpers\Html::fileInput() kartik\field\FieldRange
INPUT_FILE_WIDGET '\kartik\file\FileInput' Krajee FileInput widget kartik\file\FileInput kartik\field\FieldRange
INPUT_HTML5_INPUT 'input' Input type rendered via kartik\helpers\Html::input() kartik\field\FieldRange
INPUT_LIST_BOX 'listBox' Input type rendered via kartik\helpers\Html::listBox() kartik\field\FieldRange
INPUT_MONEY '\kartik\money\MaskMoney' Krajee Mask Money widget kartik\money\MaskMoney kartik\field\FieldRange
INPUT_PASSWORD 'passwordInput' Input type rendered via kartik\helpers\Html::passwordInput() kartik\field\FieldRange
INPUT_RADIO 'radio' Input type rendered via kartik\helpers\Html::radio() kartik\field\FieldRange
INPUT_RADIO_BUTTON_GROUP 'radioButtonGroup' Input type rendered via kartik\helpers\Html::radioButtonGroup() kartik\field\FieldRange
INPUT_RADIO_LIST 'radioList' Input type rendered via kartik\helpers\Html::radioList() kartik\field\FieldRange
INPUT_RANGE '\kartik\range\RangeInput' Krajee RangeInput widget kartik\range\RangeInput kartik\field\FieldRange
INPUT_RATING '\kartik\rating\StarRating' Krajee StarRating widget kartik\rating\StarRating kartik\field\FieldRange
INPUT_SELECT2 '\kartik\select2\Select2' Krajee Select2 widget kartik\select2\Select2 kartik\field\FieldRange
INPUT_SORTABLE '\kartik\sortinput\SortableInput' Krajee Sortable Input widget kartik\sortinput\SortableInput kartik\field\FieldRange
INPUT_SPIN '\kartik\touchspin\TouchSpin' Krajee TouchSpin widget kartik\touchspin\TouchSpin kartik\field\FieldRange
INPUT_SWITCH '\kartik\switchinput\SwitchInput' Krajee SwitchInput widget kartik\switchinput\SwitchInput kartik\field\FieldRange
INPUT_TEXT 'textInput' Input type rendered via kartik\helpers\Html::textInput() kartik\field\FieldRange
INPUT_TEXTAREA 'textarea' Input type rendered via kartik\helpers\Html::textarea() kartik\field\FieldRange
INPUT_TIME '\kartik\time\TimePicker' Krajee TimePicker widget kartik\time\TimePicker kartik\field\FieldRange
INPUT_TREEVIEW '\kartik\tree\TreeViewInput' Krajee Treeview Input widget kartik\tree\TreeViewInput kartik\field\FieldRange
INPUT_TYPEAHEAD '\kartik\typeahead\Typeahead' Krajee Typeahead widget kartik\typeahead\Typeahead kartik\field\FieldRange
INPUT_WIDGET 'widget' Input type rendered via kartik\base\Widget kartik\field\FieldRange

Property Details

$addInputCss public property

The additional CSS class that will be appended to input markup

public string $addInputCss 'form-control'
$attribute1 public property

The first field's model attribute that this widget is associated with.

public string $attribute1 null
$attribute2 public property

The second field's model attribute that this widget is associated with.

public string $attribute2 null
$container public property

The HTML options for the main container

public array $container = []
$errorContainer public property

The HTML attributes for the common error block container

public array $errorContainer = []
$fieldConfig1 public property

The active field configuration for attribute1 (applicable when $form property is set).

See also [[kartik\form\ActiveField]].

public array $fieldConfig1 = []
$fieldConfig2 public property

The active field configuration for attribute2 (applicable when $form property is set)

See also [[kartik\form\ActiveField]].

public array $fieldConfig2 = []
$form public property

The form instance, if used with active form

$items1 public property

The option data items for first field if $type is set to INPUT_DROPDOWN_LIST, INPUT_LIST_BOX, INPUT_CHECKBOX_LIST, INPUT_RADIO_LIST, INPUT_CHECKBOX_BUTTON_GROUP, INPUT_RADIO_BUTTON_GROUP.

See also [[yii\helpers\Html::dropDownList()]] for details on how this is to be rendered.

public array $items1 = []
$items2 public property

The option data items for second fieldif $type is set to INPUT_DROPDOWN_LIST, INPUT_LIST_BOX, INPUT_CHECKBOX_LIST, INPUT_RADIO_LIST, INPUT_CHECKBOX_BUTTON_GROUP, INPUT_RADIO_BUTTON_GROUP.

See also [[yii\helpers\Html::dropDownList()]] for details on how this is to be rendered.

public array $items2 = []
$label public property

The label to be displayed. Positioning of the label can be controlled by the $template property.

public string $label ''
$labelOptions public property

HTML attributes for the label.

public array $labelOptions = []
$model public property

The data model that this widget is associated with.

public yii\base\Model $model null
$name1 public property

The first field's input name. This must be set if $model and $attribute1 are not set.

public string $name1 null
$name2 public property

The second field's input name. This must be set if $model and $attribute2 are not set.

public string $name2 null
$options public property

The HTML attributes for the generated widget input. This has the input-group CSS class set by default.

public array $options = []
$options1 public property

The HTML attributes for the first field's input tag.

public array $options1 = []
$options2 public property

The HTML attributes for the second field's input tag.

public array $options2 = []
$separator public property

The field separator string between first and second field

public string $separator '← to →'
$separatorOptions public property

HTML attributes for the separator. The following array keys are specially identified:

  • tag: string, the HTML tag used to render the separator container. Defaults to span.

Defaults to:

  • ['class' => 'input-group-addon'] for $bsVersion = 3.x
  • ['class' => 'input-group-text'] for $bsVersion = 4.x
$template public property

The template to render the widget.

The following special tokens will be replaced:

  • {label}: will be replaced by the $label property
  • {widget}: will be replaced by the range widget markup
  • {error}: the common error block for the widget.
public string $template '{label}{widget}{error}'
$type public property

The input types for the field (must be one of the kartik\field\FieldRange::INPUT_XXX constants.

public string $type self::INPUT_TEXT
$useAddons public property

Whether to implement and render bootstrap 3 addons using kartik\form\ActiveField.

public boolean $useAddons true
$value1 public property

The first field's input value.

public string $value1 null
$value2 public property

The second field's input value.

public string $value2 null
$widgetClass public property

The widget class to use if $type is set to INPUT_WIDGET.

public string $widgetClass null
$widgetContainer public property

The HTML attributes for the widget container

public array $widgetContainer = []
$widgetOptions1 public property

The widget options for the first field if $type is INPUT_WIDGET or one of the Krajee input inputs from \kartik\widgets.

public array $widgetOptions1 = []
$widgetOptions2 public property

The widget options for the second field if $type is INPUT_WIDGET or one of the inputs from \kartik\widgets.

public array $widgetOptions2 = []

Method Details

getDatePicker() protected method

Generate the range input markup for kartik\date\DatePicker widget.

protected string getDatePicker ( )
return string

The date picker range input

throws Exception
getFormInput() protected method

Generate the input markup for an kartik\form\ActiveForm input.

protected string getFormInput ( $i )
$i integer

The input serial number

return string

The form input markup

getInput() protected method

Generate the input markup for a normal input.

protected string getInput ( $i )
$i integer

The input serial number

return string

The input markup

throws Exception
hasModel() protected method

Checks whether the current widget has a model assigned to it.

protected boolean hasModel ( )
return boolean

Whether this widget is associated with a data model.

init() public method

Initializes the object.

This method is called at the end of the constructor. The default implementation will trigger an EVENT_INIT event.

public void init ( )
throws yii\base\InvalidConfigException
initOptions() public method

Initializes the widget options.

public void initOptions ( )
throws yii\base\InvalidConfigException
registerAssets() protected method

Registers client assets for kartik\field\FieldRange widget.

protected void registerAssets ( )
renderWidget() protected method

Renders the field range widget.

protected void renderWidget ( )
throws yii\base\InvalidConfigException
throws Exception
run() public method

Executes the widget.

public string|void run ( )
return string|void

The rendering result may be directly "echoed" or returned as a string

throws yii\base\InvalidConfigException
throws Exception
setWidgetOptions() protected method

Sets widget options.

protected void setWidgetOptions ( $i )
$i integer

The field seq num

validateSettings() public method

Validates the widget settings.

public void validateSettings ( )
throws yii\base\InvalidConfigException