コード例 #1
0
 public function handle_set_form_values()
 {
     $form = new FormHelper(array(), $this->dataProvider->getEditFormConfig());
     $url = new UrlHelper();
     // let's not worry about validation right now.
     $values = json_decode($url->get("values_json", "{}"), true);
     if ($form->validate($values)) {
         $this->dataProvider->setRow($url->get("item_id", null), $values);
         FlashBag::add("alert", "Item has been updated", "success");
         return array('type' => 'json', 'data' => array('success' => true));
     } else {
         // TODO show errors on validation fail
         throw new \Exception("Cannot validate values");
     }
 }