yii\widgets\ActiveField::input PHP Метод

input() публичный Метод

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 input($type, $options = [])
    {
        $options = array_merge($this->inputOptions, $options);
        $this->adjustLabelFor($options);
        $this->parts['{input}'] = Html::activeInput($type, $this->model, $this->attribute, $options);
        return $this;
    }

Usage Example

Пример #1
0
    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}']);
    }
All Usage Examples Of yii\widgets\ActiveField::input