kartik\builder\TabularForm::getCellValue PHP Method

getCellValue() protected method

Generates a cell value.
protected getCellValue ( string $attribute, mixed $settings ) : string
$attribute string the model attribute.
$settings mixed the configuration for the attribute.
return string the parsed cell value.
    protected function getCellValue($attribute, $settings)
    {
        $formatter = ArrayHelper::getValue($this->gridSettings, 'formatter', Yii::$app->formatter);
        return function ($model, $key, $index, $widget) use($attribute, $settings, $formatter) {
            $staticInput = '';
            foreach ($settings as $k => $v) {
                if ($v instanceof Closure) {
                    $settings[$k] = call_user_func($v, $model, $key, $index, $widget);
                }
            }
            $type = ArrayHelper::getValue($settings, 'type', self::INPUT_RAW);
            if ($type === self::INPUT_STATIC || $this->staticOnly || $type === self::INPUT_HIDDEN_STATIC) {
                $staticInput = $this->getStaticInput($type, $model, $index, $settings, $attribute, $formatter);
                if ($type !== self::INPUT_HIDDEN_STATIC) {
                    return $staticInput;
                }
            }
            $i = empty($key) ? $index : (is_array($key) ? implode($this->compositeKeySeparator, $key) : $key);
            $options = ArrayHelper::getValue($settings, 'options', []);
            if ($model instanceof Model) {
                if ($type === self::INPUT_HIDDEN_STATIC) {
                    return $staticInput . Html::activeHiddenInput($model, "[{$i}]{$attribute}", $options);
                }
                return static::renderActiveInput($this->form, $model, "[{$i}]{$attribute}", $settings);
            } else {
                $models = $this->dataProvider->getModels();
                $settings['value'] = empty($models[$index][$attribute]) ? null : $models[$index][$attribute];
                if ($type === self::INPUT_HIDDEN_STATIC) {
                    return $staticInput . Html::hiddenInput("{$this->formName}[{$i}][{$attribute}]", $settings['value'], $options);
                }
                return static::renderInput("{$this->formName}[{$i}][{$attribute}]", $settings);
            }
        };
    }