public function saveGenre() { $this->unlinkAll('genre', true); if (isset($this->_genre) && is_array($this->_genre)) { foreach ($this->_genre as $genreLabel) { $genre = new Genre(); $genre->label = $genreLabel; $genre->link('movie', $this); } } }
/** * @return \yii\db\ActiveQuery */ public function getMusic() { return $this->hasOne(Genre::className(), ['Id' => 'musicId']); }