public function action_add() { $user = $this->is_logged(); if ($user === false) { return Redirect::to_action('login'); } else { $kind = Kind::all(); $form = Session::get('form'); $band_selected = null; $id_band = null; if (isset($_POST['band'])) { $band_selected = $_POST['band']; } if (isset($form['id_group'])) { $band_selected = $form['id_group']; } if (isset($_POST['id_group'])) { $band_selected = $_POST['id_group']; } if (isset($form)) { $album_selected = $form['album']; } else { $album_selected = null; } if (isset($band_selected)) { $album = Album::get_from_id($band_selected); if (count($album) != 0) { $album_for_select = array(); foreach ($album as $value) { $album_for_select[$value->id_album] = $value->name_album; } if (isset($_POST['id_band'])) { $band_selected = $_POST['band']; } if (isset($_POST['band'])) { $band_selected = $_POST['band']; } } else { $album_for_select = null; $this->_error_msg = "Ce groupe n'a pas d'album, veuillez l'ajouter! </br>"; } } else { $album_for_select = null; } $band = Band::all(); $band_for_select = array(); foreach ($band as $value) { $band_for_select[$value->attributes['id_band']] = $value->attributes['name_band']; } return View::make('content.song.add')->with('band', $band_for_select)->with('band_selected', $band_selected)->with('album_selected', $album_selected)->with('album', $album_for_select)->with('msg', $this->_error_msg)->with('kinds', $kind); } }