Trait kartik\base\AddonTrait

Implemented bykartik\base\Html5Input, kartik\color\ColorInput, kartik\form\ActiveField, kartik\range\RangeInput, kartik\select2\Select2, kartik\widgets\ActiveField, kartik\widgets\ColorInput, kartik\widgets\RangeInput, kartik\widgets\Select2

AddonTrait includes methods to render bootstrap styled addons based on the addon property in classes that use this trait.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$addon array Addon to prepend or append to the widget (based on bootstrap input group styling). kartik\base\AddonTrait

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getAddonContent() Parses and returns addon content. kartik\base\AddonTrait
renderAddonItem() Renders an addon item based on its configuration kartik\base\AddonTrait

Property Details

$addon public property

Addon to prepend or append to the widget (based on bootstrap input group styling).

  • prepend: array|string, the prepend addon configuration. If set as a string will be rendered as is. If set as an array, the following properties can be set:
    • content: string, the prepend addon content.
    • asButton: _boolean, whether the addon is a button or button group. Defaults to false`.
  • append: array|string, the append addon configuration. If set as a string will be rendered as is. If set as an array, the following properties can be set:
    • content: string, the append addon content.
    • asButton: _boolean, whether the addon is a button or button group. Defaults to false`.
  • preCaption : array|string, the addon content placed before the caption. Note that this property is applicable for kartik\base\Html5Input widget only. If set as a string, will be rendered as a raw markup without HTML encoding. If set as an array, the following options can be set:
    • content : string, the append addon content
    • asButton : boolean, whether the addon is a button
    • options : _array the HTML attributes for the append addon
  • contentBefore: string, content placed before the addon
  • contentAfter: string, content placed after the addon
  • groupOptions: array, HTML options for the input group
public array $addon = []

Method Details

getAddonContent() protected method

Parses and returns addon content.

protected string getAddonContent ( $type, $bsVer null )
$type string

The addon type prepend or append. If any other value is set, it will default to prepend

$bsVer integer|null

Bootstrap version

throws Exception
renderAddonItem() protected static method

Renders an addon item based on its configuration

protected static string renderAddonItem ( $config, $bsVer null )
$config array

The addon item configuration

$bsVer integer|null

Bootstrap version

throws Exception