예제 #1
0
 /**
  * Update a field.
  */
 public function post_edit()
 {
     if (!isset($_POST['id'])) {
         return $this->error(__('Missing parameter: id'));
     }
     $obj = new ExtendedFields($_POST['id']);
     if ($obj->error) {
         return $this->error(__('Field not found.'));
     }
     $obj->label = isset($_POST['label']) ? $_POST['label'] : $obj->label;
     $obj->type = isset($_POST['type']) ? $_POST['type'] : $obj->type;
     $obj->options = isset($_POST['options']) ? $_POST['options'] : $obj->options;
     $obj->required = isset($_POST['required']) ? $_POST['required'] : $obj->required;
     if (!$obj->put()) {
         return $this->error(__('An unknown error occurred.'));
     }
     return $obj->orig();
 }