示例#1
0
 /**
  * Edit tab.
  *
  * @param integer $id Tab ID
  */
 public function action_edit($id)
 {
     $tab = CustomTab::find($id);
     // Check if the form has been submitted.
     if (Request::method() == 'post') {
         $tab->set(array('label' => Request::post('label', $tab->label), 'url' => Request::post('url', $tab->url), 'groups' => implode(',', Request::post('groups', explode(',', $tab->groups))), 'display_order' => Request::post('display_order', $tab->display_order), 'project_id' => Request::post('project_id', $tab->project_id)));
         // Save and redirect
         if ($tab->save()) {
             Request::redirectTo('/admin/custom_tabs');
         }
     }
     View::set(compact('tab'));
 }
示例#2
0
 /**
  * Edit field page.
  *
  * @param integer $id
  */
 public function action_edit($id)
 {
     // Get field
     $field = CustomField::find($id);
     // Verify project
     if ($field->project_id != $this->project->id) {
         return $this->show_no_permission();
     }
     // Check if the form has been submitted
     if (Request::method() == 'post') {
         $data = array();
         // Loop over properties
         foreach (CustomField::properties() as $property) {
             // Check if it's set and not empty
             if (isset(Request::$post[$property])) {
                 $data[$property] = Request::$post[$property];
             }
         }
         if ($this->is_api) {
             $data['is_required'] = Request::post('is_required', $field->is_required);
             $data['multiple'] = Request::post('multiple', $field->multiple);
         } else {
             $data['is_required'] = Request::post('is_required', 0);
             $data['multiple'] = Request::post('multiple', 0);
         }
         // Set field properties
         $field->set($data);
         // Save and redirect
         if ($field->save()) {
             if ($this->is_api) {
                 return \API::response(1, array('field' => $field));
             } else {
                 Request::redirectTo($this->project->href('settings/custom_fields'));
             }
         }
     }
     // Send field object to view
     View::set(compact('field'));
 }