判断当不允许为空时添加错误消息
@param Model $object
@param string $attribute
@throws \Exception
776316
protected function validateEmpty($object, $attribute)
    {
        if (!$this->allowEmpty) {
            $this->addError($object, $attribute, $this->emptyMessage);
        }
    }
665809
public function run($id, $attribute)
    {
        if (Yii::app()->getRequest()->isPostRequest) {
            $model = $this->loadModel($id);
            $model->$attribute = ($model->$attribute == $this->noValue) ? $this->yesValue : $this->noValue;
            $success = $model->save(false, array($attribute));

            if (Yii::app()->getRequest()->isAjaxRequest) {
                echo $success ? $this->ajaxResponseOnSuccess : $this->ajaxResponseOnFailed;
                exit(0);
            }
            if ($this->redirectRoute !== null) {
                $this->getController()->redirect($this->redirectRoute);
            }
        } else {
            throw new CHttpException(Yii::t('zii', 'Invalid request'));
        }
    }
897017
public function add_on_empty($attribute, $msg)
	{
		if (empty($msg))
			$msg = self::$DEFAULT_ERROR_MESSAGES['empty'];

		if (empty($this->model->$attribute))
			$this->add($attribute, $msg);
	}
645746
public function removeAttribute(string $attribute)
    {
        if (empty($attribute)) {
            Throw new ColumnException('An empty attribute is not allowed.');
        }

        unset($this->attributes[$attribute]);
    }
1115755
protected function processAttributeToResource($object, ResourceObject $resource, Attribute $definition)
    {
        $name   = $definition->getName();
        $getter = $definition->getGetter();

        $value = $object->$getter();

        if ($value === null && ! $definition->getProcessNull()) {
            return;
        }

        $value = $this->typeManager->toResource($definition, $value);

        $resource->setAttribute($name, $value);
    }
91204
public function resolveForDisplay($model, $attribute = null)
    {
        try {
            parent::resolveForDisplay($model, $this->attribute.'_type');
        } catch (\Exception $e) {
            //
        }
 
        foreach ($this->meta['types'] as $index => $type) {
            $this->meta['types'][$index]['active'] =
                $this->mapToKey($type['value']) == $model->{$this->attribute . '_type'};

            foreach ($type['fields'] as $field) {
                try {
                    $field->resolveForDisplay($model->{$this->attribute});
                } catch (\Exception $e) {
                    //
                }
            }
        }
    }
287314
public function storeObjectAttribute( $attribute )
    {
        /** @var $eZTags eZTags */
        $eZTags = $attribute->content();
        if ( $eZTags instanceof eZTags )
            $eZTags->store( $attribute );
    }
172361
protected function validateAttribute($object,$attribute) {
        $value=$object->$attribute;
        if($this->allowEmpty && $this->isEmpty($value))
            return;
        elseif(!is_array($value)) {
            $message=$this->message!==null?$this->message:Yii::t('P2Module.p2','{attribute} is not valid.');
            $this->addError($object,$attribute,$message);
        }

        $length=count($value);
        if($this->min!==null && $length<$this->min) {
            $message=$this->tooShort!==null?$this->tooShort:Yii::t('P2Module.p2','{attribute} is too short (minimum is {min} entries).');
            $this->addError($object,$attribute,$message,array('{min}'=>$this->min));
        }
        if($this->max!==null && $length>$this->max) {
            $message=$this->tooLong!==null?$this->tooLong:Yii::t('P2Module.p2','{attribute} is too long (maximum is {max} entries).');
            $this->addError($object,$attribute,$message,array('{max}'=>$this->max));
        }
        if($this->is!==null && $length!==$this->is) {
            $message=$this->message!==null?$this->message:Yii::t('P2Module.p2','{attribute} is of the wrong length (should be {length} entries).');
            $this->addError($object,$attribute,$message,array('{length}'=>$this->is));
        }
    }
481044
public function validateAttribute($model, $attribute)
    {
        if (
            $this->targetClass !== null
            && $model->$attribute instanceof $this->targetClass
            && !empty($model->$attribute->isNewRecord)
        ) {
            return;
        }

        if ($model->isRelationPopulated($attribute)) {
            return;
        }

        parent::validateAttribute($model, $attribute);
    }
303118
protected function processResourceToAttribute($object, ResourceObject $resource, Attribute $definition)
    {
        $name = $definition->getName();

        if (! $resource->hasAttribute($name)) {
            return;
        }

        $value = $resource->getAttribute($name);

        if ($value === null && ! $definition->getProcessNull()) {
            return;
        }

        $value  = $this->typeManager->fromResource($definition, $value);
        $setter = $definition->getSetter();

        $object->$setter($value);
    }
1041001
public function setPostAttribute($model, $attribute)
    {
        if ($attributeValue = Yii::$app->request->post($attribute, null)) {
            $model->setAttribute($attribute, $attributeValue);
        }
    }
498360
public function renderMultiInput ($model, $attribute)
    {
        $inputName = Html::getInputName($model, $attribute);
        Html::addCssClass($this->chooseButtonClass, "btn {$this->_hashVar}");
        $eles = [];
        $eles[] = Html::textInput($attribute, null, ['class' => 'form-control', 'readonly' => 'readonly']);
        $eles[] = Html::hiddenInput($inputName, null);
        $eles[] = Html::tag('span', Html::button('选择图片', $this->chooseButtonClass), ['class' => 'input-group-btn']);

        return Html::tag('div', implode("\n", $eles), ['class' => 'input-group']);
    }
274802
protected function validateAttribute($object, $attribute)
    {
        $value = $object->{$attribute};
        if ($this->isEmpty($value)) {
            $this->validateEmpty($object, $attribute);
            return;
        }
        if (null !== $this->compareValue) {
            $compareTo = $compareValue = $this->compareValue;
        } else {
            $compareAttribute = null === $this->compareAttribute ? $attribute . '_repeat' : $this->compareAttribute;
            $compareValue = $object->{$compareAttribute};
            $compareTo = $object->getAttributeLabel($compareAttribute);
        }

        switch ($this->operator) {
            case '=':
            case '==':
                if (($this->strict && $value !== $compareValue) || (!$this->strict && $value != $compareValue)) {
                    $message = (null !== $this->message) ? $this->message : '"{attribute}"必须和"{compareAttribute}"相等';
                }
                break;
            case '!=':
                if (($this->strict && $value === $compareValue) || (!$this->strict && $value == $compareValue)) {
                    $message = (null !== $this->message) ? $this->message : '"{attribute}"必须不等于"{compareAttribute}"';
                }
                break;
            case '>':
                if ($value <= $compareValue) {
                    $message = (null !== $this->message) ? $this->message : '"{attribute}"必须大于"{compareAttribute}"';
                }
                break;
            case '>=':
                if ($value < $compareValue) {
                    $message = (null !== $this->message) ? $this->message : '"{attribute}"必须大于等于"{compareAttribute}"';
                }
                break;
            case '<':
                if ($value >= $compareValue) {
                    $message = (null !== $this->message) ? $this->message : '"{attribute}"必须小于"{compareAttribute}"';
                }
                break;
            case '<=':
                if ($value > $compareValue) {
                    $message = (null !== $this->message) ? $this->message : '"{attribute}"必须小于等于"{compareAttribute}"';
                }
                break;
            default:
                throw new Exception(str_cover('无效的对比操作符"{operator}"', [
                    '{operator}' => $this->operator,
                ]), 101400201);
        }
        if (!empty($message)) {
            $this->addError($object, $attribute, $message, [
                '{compareAttribute}' => $compareTo,
            ]);
        }
    }
113736
protected function isAllowedAttribute(
        DataInterface $object,
        $attribute,
        /** @noinspection PhpUnusedParameterInspection */
        $format = null,
        array $context = []
    ) {
        // If normalizing by reference, we just check if it's among the allowed attributes
        if ($this->byReferenceHandler->isByReference($context)) {
            return \in_array($attribute, $this->referenceAttributes, true);
        }

        // Check ignored attributes
        if (\in_array($attribute, $this->ignoredAttributes, true)) {
            return false;
        }

        return $this->isGroupAllowed($object, $attribute, $context);
    }
894274
protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute)
    {
        foreach ($this->meta['types'] as $type) {

            if($request->get($attribute) == $type['value']) {
                $relatedModel = new $type['value'];

                if($this->mapToKey($type['value']) == $model->{$this->attribute . '_type'}) {
                    $relatedModel = $relatedModel->newQuery()->findOrFail($model->{$this->attribute . '_id'});
                } elseif(! is_null($model->{$this->attribute . '_type'})) {
                    $oldRelatedClass = $this->mapToClass($model->{$this->attribute . '_type'});
                    $oldRelatedModel = (new $oldRelatedClass)->newQuery()->findOrFail($model->{$this->attribute . '_id'});
                    $oldRelatedModel->delete();
                }

                foreach ($type['fields'] as $field) {
                    $field->fill($request, $relatedModel);
                }

                $relatedModel->save();

                $model->{$this->attribute.'_id'} = $relatedModel->id;
                $model->{$this->attribute.'_type'} = $this->mapToKey($type['value']);
            }

        }
    }
1255555
function addAttribute(Attribute $attribute)
    {
        $attribute->setRelation($this);
        $this->attributes[$attribute->getName()] = $attribute;
        return $this;
    }
714576
public function validateAttribute($model, $attribute)
    {
        $value = $model->$attribute;
        $captcha = $this->createCaptchaAction($model);
        $valid = !is_array($value) && $captcha->validate($value);
        $isExpired = $captcha->isExpired();

        $result = $isExpired ? [$this->getMessageForExpiredCaptcha(), []] : ($valid ? null : [$this->message, []]);
//        $result = $this->validateValue($model->$attribute, $model);
        if (!empty($result)) {
            $this->addError($model, $attribute, $result[0], $result[1]);
        }
    }