// store the submitted values in an array
if (!$params) {
- $params = $this->controller->exportValues($this->_name);
+ $params = $this->getSubmittedValues();
+ }
+ else {
+ CRM_Core_Error::deprecatedWarning('passing params into postProcess is deprecated. Match parent function');
}
// Set activity type id.
return $this->context;
}
+ /**
+ * Get values submitted by the user.
+ *
+ * Compared with $this->controller->exportValues this has a couple of changes
+ * 1) any fields declared in $this->submittableMoneyFields will be de-formatted first.
+ * 2) it is possible to store access fields from related forms if they
+ * are declared in `getSubmittableFields()`. This is notably used in imports
+ * to combine fields from the various screens & save the resulting 'submitted_values'
+ * to the UserJob.
+ *
+ * @return array
+ */
+ public function getSubmittedValues(): array {
+ $values = [];
+ foreach (array_keys($this->getSubmittableFields()) as $key) {
+ $values[$key] = $this->getSubmittedValue($key);
+ }
+ return $values;
+ }
+
+ /**
+ * Get the fields that can be submitted in this form flow.
+ *
+ * To make fields in related forms (ie within the same wizard like
+ * Contribution_Main and Contribution_Confirm) accessible you can override
+ * this function as CRM_Import_Forms does.
+ *
+ * @return string[]
+ */
+ protected function getSubmittableFields(): array {
+ $fieldNames = array_keys($this->controller->exportValues($this->_name));
+ return array_fill_keys($fieldNames, $this->_name);
+ }
+
/**
* Set context variable.
*/
}
- /**
- * Get values submitted on any form in the multi-page import flow.
- *
- * @return array
- */
- public function getSubmittedValues(): array {
- $values = [];
- foreach (array_keys($this->getSubmittableFields()) as $key) {
- $values[$key] = $this->getSubmittedValue($key);
- }
- return $values;
- }
-
/**
* Get the available datasource.
*
* 2) User changes the source to SQL - the ajax updates the html but the
* form was built with the expectation that the csv-specific fields would be
* required.
- * 3) When the user submits Quickform calls preProcess and buildForm and THEN
+ * 3) When the user submits QuickForm calls preProcess and buildForm and THEN
* retrieves the submitted values based on what has been added in buildForm.
* Only the submitted values for fields added in buildForm are available - but
* these have to be added BEFORE the submitted values are determined. Hence
* This is called as a snippet in DataSourceConfig and
* also from DataSource::buildForm to add the fields such
* that quick form picks them up.
+ *
+ * @throws \CRM_Core_Exception
*/
protected function getDataSourceFields(): array {
$className = $this->getDataSourceClassName();