Renders an input tag.
public input ( string $type, array $options = [] ) | ||
$type | string | the input type (e.g. `text`, `password`) |
$options | array | the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. If you set a custom `id` for the input element, you may need to adjust the [[$selectors]] accordingly. |
public function testInput() { $expectedValue = <<<EOD <input type="password" id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]"> EOD; $this->activeField->input("password"); $this->assertEquals($expectedValue, $this->activeField->parts['{input}']); // with options $expectedValue = <<<EOD <input type="password" id="dynamicmodel-attributename" class="form-control" name="DynamicModel[attributeName]" weird="value"> EOD; $this->activeField->input("password", ['weird' => 'value']); $this->assertEquals($expectedValue, $this->activeField->parts['{input}']); }
/** * @inheritdoc */ public function input($type, $options = []) { $this->initPlaceholder($options); if ($type != 'range' || $type != 'color') { Html::addCssClass($options, $this->addClass); } $this->initDisability($options); return parent::input($type, $options); }
/** * Renders a week input. * @param array $options * @return ActiveField */ public function weekInput($options = []) { Html::addCssClass($options, ['input' => 'week']); return parent::input('week', $options); }
/** * Renders a email input. * This method will generate the "name" and "value" tag attributes automatically for the model attribute * unless they are explicitly specified in `$options`. * @param array $options the tag options in terms of name-value pairs. These will be rendered as * the attributes of the resulting tag. The values will be HTML-encoded using [[Html::encode()]]. * @return static the field object itself */ public function emailInput($options = []) { $options['title'] = $this->model->getAttributeLabel($this->attribute); $options['ng-model'] = ArrayHelper::remove($options, 'ng-model', 'data.' . $this->attribute); return Html::tag('md-input-container', parent::input('email', $options)); }
/** * Hidden input * @param array $options * @return \sersid\smartadmin\ActiveField */ public function hidden($options = []) { $this->template = $this->hiddenTemplate; return parent::input('hidden', $options); }
/** * @inheritdoc */ public function input($type, $options = []) { $options['title'] = $options['placeholder'] = $this->model->getAttributeLabel($this->attribute); $options['ng-model'] = 'data.' . $this->attribute; return parent::input($type, $options); }
/** * @inheritdoc */ public function input($type, $options = []) { Html::addCssClass($this->options, sprintf('form-group--%s-input', $type)); $options = array_merge($this->inputOptions, $options); $options['title'] = $this->model->getAttributeLabel($this->attribute); $options['ng-model'] = ArrayHelper::remove($options, 'ng-model', sprintf('data.%s', $this->attribute)); $this->beforeRenderInput(__METHOD__, $options); return parent::input($type, $options); }