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;
    }