示例#1
0
 protected function onPost(\Controllers\Request $input)
 {
     $id = $input->get('id');
     $this->data['update_success'] = false;
     try {
         $obj = Order::createFromInput($input, $id);
         $this->data['update_success'] = true;
     } catch (\App\Exceptions\Validation $ex) {
         $this->data['errors'] = $ex->validator->errors();
     } catch (\Exception $ex) {
         $this->errors->add('update-error', $ex->getMessage());
     }
     return parent::onPost($input);
 }
示例#2
0
 protected function onPost(\Controllers\Request $input)
 {
     $this->data['create_success'] = false;
     try {
         $obj = Order::createFromInput($input);
         $this->data['create_success'] = true;
         $this->view = 'admin.orders.edit';
         $this->data['order'] = $obj;
         return $this->redirect($this->plugin->orders_url('update', ['id' => $obj->id]));
     } catch (\App\Exceptions\Validation $ex) {
         dd($this->input);
         $this->data['errors'] = $ex->validator->errors();
     } catch (\Exception $ex) {
         $this->errors->add('create-error', $ex->getMessage());
     }
     return parent::onPost($input);
 }