コード例 #1
0
 public function editar($id)
 {
     $unidade = Unidade::get($id);
     if ($unidade) {
         if (is_post) {
             try {
                 $unidade = $this->_data($unidade);
                 Unidade::salvar($unidade);
                 $this->_flash('alert alert-success fade in', 'Unidade alterada com sucesso!');
                 $this->_redirect('~/unidade/');
             } catch (ValidationException $e) {
                 $this->_flash('alert alert-error fade in', $e->getMessage());
             } catch (Exception $e) {
                 $this->_flash('alert alert-error fade in', 'Ocorreu um erro ao tentar editar a unidade!');
             }
         }
         $this->_set('unidade', $unidade);
         return $this->_view('cadastrar');
     }
     return $this->_snippet('notfound');
 }