/** * Handle processing the form when it's posted, such as saving and handling errors. */ protected function processPost() { if (!$this->formObj) { return false; } if ($this->formObj->formSubmitted()) { // Form is valid, so save data if ($this->formObj->formValid()) { $originalFormValues = $this->formObj->getFormValues(); // Add optional filter to tweak the form values before saving if ($this->filterBeforeSaveFunction && function_exists($this->filterBeforeSaveFunction)) { $formValues = call_user_func($this->filterBeforeSaveFunction, $originalFormValues, $this); } else { $formValues = $originalFormValues; } // Now save the form values as normal. $this->handleSave($formValues); // Optional function once data has been saved if ($this->afterSaveFunction && function_exists($this->afterSaveFunction)) { call_user_func($this->afterSaveFunction, $formValues, $originalFormValues, $this); } } else { $this->messages = $this->showListOfErrors($this->formObj->getListOfErrors()); } } }
/** * Handle processing the form when it's posted, such as saving and handling errors. */ protected function processPost() { if (!$this->formObj) { return false; } if ($this->formObj->formSubmitted()) { // Form is valid, so save data if ($this->formObj->formValid()) { $originalFormValues = $this->formObj->getFormValues(); // Add optional function to validate the data $gotFnErrorMsg = false; if ($this->filterExtraValidationFunction && function_exists($this->filterExtraValidationFunction)) { $gotFnErrorMsg = call_user_func($this->filterExtraValidationFunction, $originalFormValues, $this); } // Got an error message, so show and abort. if ($gotFnErrorMsg) { $this->messages = $this->showMessage($gotFnErrorMsg, true); return false; } // Add optional filter to tweak the form values before saving if ($this->filterBeforeSaveFunction && function_exists($this->filterBeforeSaveFunction)) { $formValues = call_user_func($this->filterBeforeSaveFunction, $originalFormValues, $this); // If we're modifying values, then we need to update the data being stored in the form $this->loadDefaults($formValues); } else { $formValues = $originalFormValues; } // Now save the form values as normal. $this->handleSave($formValues); // Optional function once data has been saved if ($this->afterSaveFunction && function_exists($this->afterSaveFunction)) { call_user_func($this->afterSaveFunction, $formValues, $originalFormValues, $this); } } else { $this->messages .= $this->showListOfErrors($this->formObj->getListOfErrors()); } } }