yii\db\BaseActiveRecord::getAttributeHint PHP Method

getAttributeHint() public method

If the attribute looks like relatedModel.attribute, then the attribute will be received from the related model.
See also: attributeHints()
Since: 2.0.4
public getAttributeHint ( string $attribute ) : string
$attribute string the attribute name
return string the attribute hint
    public function getAttributeHint($attribute)
    {
        $hints = $this->attributeHints();
        if (isset($hints[$attribute])) {
            return $hints[$attribute];
        } elseif (strpos($attribute, '.')) {
            $attributeParts = explode('.', $attribute);
            $neededAttribute = array_pop($attributeParts);
            $relatedModel = $this;
            foreach ($attributeParts as $relationName) {
                if ($relatedModel->isRelationPopulated($relationName) && $relatedModel->{$relationName} instanceof self) {
                    $relatedModel = $relatedModel->{$relationName};
                } else {
                    try {
                        $relation = $relatedModel->getRelation($relationName);
                    } catch (InvalidParamException $e) {
                        return '';
                    }
                    $relatedModel = new $relation->modelClass();
                }
            }
            $hints = $relatedModel->attributeHints();
            if (isset($hints[$neededAttribute])) {
                return $hints[$neededAttribute];
            }
        }
        return '';
    }