public function WebformAttachmentBase::preSave in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_attachment/src/Plugin/WebformElement/WebformAttachmentBase.php \Drupal\webform_attachment\Plugin\WebformElement\WebformAttachmentBase::preSave()
Acts on a webform submission element before the presave hook is invoked.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Overrides WebformElementBase::preSave
File
- modules/
webform_attachment/ src/ Plugin/ WebformElement/ WebformAttachmentBase.php, line 150
Class
- WebformAttachmentBase
- Provides a base class for 'webform_attachment' elements.
Namespace
Drupal\webform_attachment\Plugin\WebformElementCode
public function preSave(array &$element, WebformSubmissionInterface $webform_submission) {
$key = $element['#webform_key'];
$data = $webform_submission
->getData();
// Make sure attachment element never stores a value.
if (isset($data[$key])) {
unset($data[$key]);
$webform_submission
->setData($data);
}
}