/** * After the form section is initially created, call this to sanitize the data in the submission * which relates to this form section, validate it, and set it as properties on the form. * @param array $req_data should usually be $_REQUEST (the default). However, you CAN * supply a different array. Consider using set_defaults() instead however. (If you rendered * the form in the page using echo $form_x->get_html() the inputs will have the correct name * in the request data for this function to find them and populate the form with them. * If you have a flat form (with only input subsections), you can supply a flat array where keys * are the form input names and values are their values) * @param boolean $validate whether or not to perform validation on this data. Default is, * of course, to validate that data, and set errors on the invalid values. But if the data * has already been validated (eg you validated the data then stored it in the DB) you may want * to skip this step. * @return void */ public function receive_form_submission($req_data = NULL, $validate = TRUE) { parent::receive_form_submission($req_data, $validate); //create or set the model object, if it isn't already if (!$this->_model_object) { //check to see if the form indicates a PK, in which case we want to only retrieve it and update it $pk_name = $this->_model->primary_key_name(); $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name)); if ($model_obj) { $this->_model_object = $model_obj; } else { $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name()); } } //ok so the model object is set. Just set it with the submitted form data (don't save yet though) foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name => $field_value) { //only set the non-primary key if ($field_name != $this->_model->primary_key_name()) { $this->_model_object->set($field_name, $field_value); } } }
/** * Gets the item indicated by its ID. But if it's soft-deleted, pretends it doesn't exist. * @param int|string $id * @return EE_Soft_Delete_Base_Class */ public function get_one_by_ID_but_ignore_deleted($id) { return parent::get_one_by_ID($id); }