Example #1
0
 public function SaveAction($form_id)
 {
     $id = $form_id + 0;
     $item = req('item');
     try {
         $this->Validate($id, $item);
         #load old record if necessary
         #$item_old = $this->model->one($id);
         $itemdb = FormUtils::form2dbhash($item, $this->save_fields);
         FormUtils::form2dbhash_checkboxes($itemdb, $item, 'is_checkbox');
         $itemdb['dict_link_auto_id'] = $this->model_related->add_or_update_quick($item['dict_link_auto_id_iname']);
         $itemdb['dict_link_multi'] = FormUtils::multi2ids(req('dict_link_multi'));
         #TODO $itemdb['fdate_combo'] = FormUtils::date4combo($item, 'fdate_combo');
         $itemdb['ftime'] = DateUtils::timestr2int($item['ftime_str']);
         #ftime - convert from HH:MM to int (0-24h in seconds)
         $id = $this->model_add_or_update($id, $itemdb);
         fw::redirect($this->base_url . '/' . $id . '/edit');
     } catch (ApplicationException $ex) {
         $this->set_form_error($ex->getMessage());
         $this->route_redirect("ShowForm");
     }
 }