public function add() { $form = array('building_id' => '', 'name' => '', 'index' => '', 'img_uri' => '', 'active' => ''); $errors = $form; if ($_POST) { $post = new Validation($_POST); $post->pre_filter('trim', true); $post->add_rules('buildings_id', 'required', 'digit'); $post->add_rules('name', 'required'); $post->add_rules('index', 'required'); $post->add_rules('img_uri', 'required'); $post->add_rules('active', 'required'); if ($post->validate()) { // check for invilid $form = arr::overwrite($form, $post->as_array()); $people = new Person_Model(); $result = $people->save($this->input->get('person'), $person_id); } else { $form = arr::overwrite($form, $post->as_array()); client::validation_results(arr::overwrite($errors, $post->errors('hiring_employee_form_validations'))); client::messageSend("There were errors in some fields", E_USER_WARNING); } } $building = new Building_Model(); $buildings_list = $building->select_list(); $this->template->title = 'Seating::Spaces::Add'; $this->template->content = new View('pages/spaces_add'); $this->template->content->form = $form; $this->template->content->buildings_list = $buildings_list; }
public function save($person_id = null) { $person_id = (int) preg_replace('/\\.json$/i', '', $person_id); $result = null; $people = new Person_Model(); $result = $people->save($this->input->get('person'), $person_id); if ($result['success']) { } else { } if ($this->is_json_request()) { $this->json_response($result); } // die($update_context); }