/** * After this form has been initialized and is verified to be valid, * either creates a model object from its data and saves it, or updates * the model object its data represents * @throws EE_Error * @return int, 1 on a successful update, the ID of * the new entry on insert; 0 on failure */ public function save() { if (!$this->_model_object) { throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", "event_espresso"), get_class($this->_model))); } $success = $this->_model_object->save(); foreach ($this->_model->relation_settings() as $relation_name => $relation_obj) { if (isset($this->_subsections[$relation_name])) { $success = $this->_save_related_info($relation_name); } } return $success; }
/** * Gets all the related models for the specified model. It's good to use this * in case this model didn't exist for this version or something * @param \EEM_Base $model * @return \EE_Model_Relation_Base[] */ public function relation_settings(\EEM_Base $model) { $relations = array(); foreach ($model->relation_settings() as $relation_name => $relation_obj) { if ($this->is_model_name_in_this_version($relation_name)) { $relations[$relation_name] = $relation_obj; } } //filter the results, but use the old filter name return apply_filters('FHEE__Read__create_entity_from_wpdb_result__related_models_to_include', $relations, $model); }