Abstract Class humhub\modules\ui\form\widgets\JsInputWidget

Inheritancehumhub\modules\ui\form\widgets\JsInputWidget » humhub\widgets\JsWidget » humhub\components\Widget » yii\base\Widget
Subclasseshumhub\modules\content\widgets\ContentTagDropDown, humhub\modules\content\widgets\ContentTagPicker, humhub\modules\content\widgets\ContentTypePicker, humhub\modules\content\widgets\richtext\AbstractRichTextEditor, humhub\modules\content\widgets\richtext\HumHubRichTextEditor, humhub\modules\content\widgets\richtext\ProsemirrorRichTextEditor, humhub\modules\content\widgets\richtext\RichTextField, humhub\modules\space\widgets\SpacePickerField, humhub\modules\topic\widgets\TopicPicker, humhub\modules\ui\form\widgets\BasePicker, humhub\modules\ui\form\widgets\ColorPicker, humhub\modules\ui\form\widgets\DurationPicker, humhub\modules\ui\form\widgets\Markdown, humhub\modules\ui\form\widgets\MultiSelect, humhub\modules\user\widgets\UserPickerField, humhub\widgets\BasePickerField, humhub\widgets\ColorPickerField, humhub\widgets\ContentTagDropDown, humhub\widgets\DurationPicker, humhub\widgets\InputWidget, humhub\widgets\MarkdownField, humhub\widgets\MultiSelectField, humhub\widgets\RichtextField, humhub\widgets\TimeZoneDropdownAddition
Available since version1.3

InputWidget is the base class for widgets that collect user inputs.

An input widget can be associated with a data model and an attribute, or a name and a value. If the former, the name and the value will be generated automatically.

Classes extending from this widget can be used in an \yii\widgets\ActiveForm using the \yii\widgets\ActiveField::widget() method, for example like this:

<?= $form->field($model, 'from_date')->widget('WidgetClassName', [
    // configure additional widget properties here
]) ?>

For more details and usage information on InputWidget, see the guide article on forms.

See also \yii\widgets\InputWidget.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
beforeRun() Initializes the widget. humhub\modules\ui\form\widgets\JsInputWidget
getId() Returns the html id of this widget, if no id is set this function will generate an id if $autoGenerate is set to true (default). humhub\widgets\JsWidget
process() Process is a wrapper for the run method humhub\components\Widget
run() Default implementation of JsWidget. humhub\widgets\JsWidget
setDefaultOptions() Sets some default data options required by all widgets as the widget implementation and the widget evetns and initialization trigger. humhub\widgets\JsWidget
widget() Creates a widget instance and runs it. humhub\components\Widget

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getAttributes() Returns all html attributes for used by this widget and will normally inserted in the widgets root html element. humhub\widgets\JsWidget
getData() Returns an array of data-* attributes to configure your clientside js widget. humhub\widgets\JsWidget
getOptions() Assembles all widget attributes and data settings of this widget. humhub\widgets\JsWidget
getValue() humhub\modules\ui\form\widgets\JsInputWidget
hasModel() humhub\modules\ui\form\widgets\JsInputWidget

Events

Hide inherited events

EventTypeDescriptionDefined By
EVENT_CREATE humhub\libs\WidgetCreateEvent An event raised before creating a widget. humhub\components\Widget

Property Details

$attribute public property

The model attribute that this widget is associated with.

public string $attribute null
$form public property
public \yii\widgets\ActiveForm $form null
$model public property

The data model that this widget is associated with.

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

The input name. This must be set if $model and $attribute are not set.

public string $name null
$options public property

The HTML attributes for the input tag.

See also \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.

public array $options = []
$value public property

The input value.

public string $value null

Method Details

beforeRun() public method

Initializes the widget.

If you override this method, make sure you call the parent implementation first.

public void beforeRun ( )
getValue() protected method (available since version 1.3)

protected string getValue ( )
return string

The field value either by extracting from model or if no model is given $this->value

hasModel() protected method

protected boolean hasModel ( )
return boolean

Whether this widget is associated with a data model.