kartik\builder\TabularForm::getStaticInput PHP Method

getStaticInput() protected method

Generates the static input
protected getStaticInput ( string $type, Model $model, integer $index, array $settings, string $attribute, Formatter $formatter ) : string
$type string the static input type.
$model yii\base\Model the data model.
$index integer the zero based index of the item in dataProvider.
$settings array the attribute settings.
$attribute string the attribute.
$formatter yii\i18n\Formatter the formatter instance.
return string the generated static input.
    protected function getStaticInput($type, $model, $index, $settings, $attribute, $formatter)
    {
        $format = ArrayHelper::getValue($settings, 'format', 'raw');
        if ($type === self::INPUT_HIDDEN_STATIC) {
            $options = ArrayHelper::getValue($settings, 'hiddenStaticOptions', []);
        } else {
            $options = ArrayHelper::getValue($settings, 'options', []);
        }
        $val = null;
        if (isset($settings['staticValue'])) {
            $val = $settings['staticValue'];
        } else {
            if (isset($settings['value'])) {
                $val = $settings['value'];
            } elseif ($model instanceof Model) {
                $val = Html::getAttributeValue($model, $attribute);
            } elseif (($models = $this->dataProvider->getModels()) && !empty($models[$index][$attribute])) {
                $val = $models[$index][$attribute];
            }
        }
        $val = $formatter->format($val, $format);
        $prepend = ArrayHelper::getValue($settings, 'prepend', '');
        $append = ArrayHelper::getValue($settings, 'append', '');
        $val = $prepend . "\n" . $val . "\n" . $append;
        Html::addCssClass($options, 'form-control-static');
        return Html::tag('div', $val, $options);
    }