protected function prepareValue($contextParams = [])
    {
        $data = $this->getModel();
        if ($this->value instanceof \Closure) {
            $value = call_user_func($this->value, $data, $contextParams);
        } else {
            $value = null;
            if ($data instanceof ActiveRecordInterface ) {
                $relation = $data->getRelation($this->name, false);
                if ($relation !== null) {
                    $value = $relation;
                } else {
                    $value = $data->getAttribute($this->name);
                }
            } elseif ($data instanceof Model) {
                $value = $data->{$this->name};
            } elseif (is_array($data)) {
                $value = ArrayHelper::getValue($data, $this->name, null);
            } elseif(is_string($data) || is_numeric($data)) {
                $value = $data;
            }

            if ($this->defaultValue !== null && $this->isEmpty($value)) {
                $value = $this->defaultValue;
            }
        }
        return $value;
    }
protected function prepareValue($contextParams = [])
    {
        $data = $this->getModel();
        if ($this->value instanceof \Closure) {
            $value = call_user_func($this->value, $data, $contextParams);
        } else {
            $value = null;
            if ($data instanceof ActiveRecordInterface ) {
                $relation = $data->getRelation($this->name, false);
                if ($relation !== null) {
                    $value = $relation;
                } else {
                    $value = $data->getAttribute($this->name);
                }
            } elseif ($data instanceof Model) {
                $value = $data->{$this->name};
            } elseif (is_array($data)) {
                $value = ArrayHelper::getValue($data, $this->name, null);
            } elseif(is_string($data) || is_numeric($data)) {
                $value = $data;
            }

            if ($this->defaultValue !== null && $this->isEmpty($value)) {
                $value = $this->defaultValue;
            }
        }
        return $value;
    }
protected function prepareValue ( $ contextParams = [ ] ) { $ data = $ this -> getModel ( ) ; if ( $ this -> value instanceof \ Closure ) { $ value = call_user_func ( $ this -> value , $ data , $ contextParams ) ; } else { $ value = null ; if ( $ data instanceof ActiveRecordInterface ) { $ relation = $ data -> getRelation ( $ this -> name , false ) ; if ( $ relation !== null ) { $ value = $ relation ; } else { $ value = $ data -> getAttribute ( $ this -> name ) ; } } elseif ( $ data instanceof Model ) { $ value = $ data -> { $ this -> name } ; } elseif ( is_array ( $ data ) ) { $ value = ArrayHelper :: getValue ( $ data , $ this -> name , null ) ; } elseif ( is_string ( $ data ) || is_numeric ( $ data ) ) { $ value = $ data ; } if ( $ this -> defaultValue !== null && $ this -> isEmpty ( $ value ) ) { $ value = $ this -> defaultValue ; } } return $ value ; }
Prepares the value of column.
@param array $contextParams the params who passed to closure:
string $id the id of input element
string $name the name of input element
string $indexPlaceholder The index placeholder of multiple input. The {$indexPlaceholder} template will be replace by $index
int $index The index of multiple input
int $columnIndex The index of current model attributes
@return mixed
Prepares the value of column .