I18nSourceMessage::className(), 'targetAttribute'=>'id'], [['translation'], 'string'], [['language'], 'string', 'max' => 16], [['language'], 'unique', 'targetAttribute' => ['id', 'language']] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('backend', 'ID'), 'language' => Yii::t('backend', 'Language'), 'translation' => Yii::t('backend', 'Translation'), 'sourceMessage' => Yii::t('backend', 'Source Message'), 'category' => Yii::t('backend', 'Category'), ]; } public function afterFind() { $this->sourceMessage = $this->sourceMessageModel ? $this->sourceMessageModel->message : null; $this->category = $this->sourceMessageModel ? $this->sourceMessageModel->category : null; return parent::afterFind(); } /** * @return \yii\db\ActiveQuery */ public function getSourceMessageModel() { return $this->hasOne(I18nSourceMessage::className(), ['id' => 'id']); } }