protected function WebformCivicrmPostProcess::submissionValue in Webform CiviCRM Integration 8.5
Get or set a value from a webform submission Always use \Drupal\webform\WebformSubmissionInterface $webform_submission [more reliable according to JR]
Parameters
$fid: Numeric webform component id
$value: Value to set - leave empty to get a value rather than setting it
Return value
array|null field value if found
4 calls to WebformCivicrmPostProcess::submissionValue()
- WebformCivicrmPostProcess::fillDataFromSubmission in src/
WebformCivicrmPostProcess.php - Fill data array with submitted form values
- WebformCivicrmPostProcess::fillHiddenContactFields in src/
WebformCivicrmPostProcess.php - Fill values for hidden ID & CS fields
- WebformCivicrmPostProcess::getExistingContactIds in src/
WebformCivicrmPostProcess.php - Fetch contact ids from "existing contact" fields
- WebformCivicrmPostProcess::isFieldHiddenByExistingContactSettings in src/
WebformCivicrmPostProcess.php - Test whether a field has been hidden due to existing contact settings
File
- src/
WebformCivicrmPostProcess.php, line 2669 - Front-end form validation and post-processing.
Class
Namespace
Drupal\webform_civicrmCode
protected function submissionValue($fid, $value = NULL) {
if (!empty($this->form_state)) {
$form_object = $this->form_state
->getFormObject();
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = $form_object
->getEntity();
$data = $webform_submission
->getData();
}
else {
$data = $this->submission
->getData();
}
if (!isset($data[$fid])) {
return [
NULL,
];
}
// Expects an array.
$field = (array) $data[$fid];
// During submission preprocessing this is used to alter the submission
if ($value !== NULL) {
$field = (array) $value;
}
return $field;
}