[ 'class' => SaveRelationsBehavior::className(), 'relations' => ['linkType'] ], ]; } /** * @inheritdoc */ public function rules() { return [ [['language', 'name', 'link'], 'required'], [['name'], 'unique', 'targetAttribute' => ['language', 'name']], [['link'], 'url', 'on' => [self::SCENARIO_FIRST]], [['link_type_id', 'linkType'], 'safe'] ]; } /** * @return \yii\db\ActiveQuery */ public function getLinkType() { return $this->hasOne(LinkType::className(), ['id' => 'link_type_id']); } }