Ejemplo n.º 1
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Foto');
     $foto = Model_Foto::find($id);
     $val = Model_Foto::validate('edit');
     if ($val->run()) {
         $foto->imagen = Input::post('imagen');
         $foto->width = Input::post('width');
         $foto->height = Input::post('height');
         $foto->articulo_id = Input::post('articulo_id');
         $foto->dimension_id = Input::post('dimension_id');
         $foto->estado = Input::post('estado');
         if ($foto->save()) {
             Session::set_flash('success', 'Updated foto #' . $id);
             Response::redirect('foto');
         } else {
             Session::set_flash('error', 'Could not update foto #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $foto->imagen = $val->validated('imagen');
             $foto->width = $val->validated('width');
             $foto->height = $val->validated('height');
             $foto->articulo_id = $val->validated('articulo_id');
             $foto->dimension_id = $val->validated('dimension_id');
             $foto->estado = $val->validated('estado');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('foto', $foto, false);
     }
     $this->template->title = "Fotos";
     $this->template->content = View::forge('foto/edit');
 }