Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/4.1.0'
Browse files Browse the repository at this point in the history
Release/4.1.0
  • Loading branch information
MdNadimHossain committed May 7, 2024
2 parents 78b397c + 7826b7d commit 260c020
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tide_webform.module
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,26 @@ function tide_webform_webform_submission_presave(WebformSubmission $webform_subm
// See /Drupal/Core/Form/FormValidator.php $is_empty_value.
$submission_data = $webform_submission->getData();
foreach ($elements as $key => $element) {
if ($element['#type'] == 'number') {
// It will not validate for multi step form.
if (isset($element['#type']) && $element['#type'] == 'wizard_page') {
return;
}
if (isset($element['#type']) && $element['#type'] == 'number') {
if (is_numeric($submission_data[$key])) {
$submission_data[$key] = strval($submission_data[$key]);
$webform_submission->setData($submission_data);
}
}
// SDPAP-6627 temporary fix until contrib module patch is created.
// @todo: refactior the code and submit a patch.
// Look at webform issue - 3170790.
// Server side validation from API submission.
if (isset($element['#required']) && $element['#required'] == TRUE) {
if (empty($submission_data[$key]) && $submission_data[$key] == "") {
// Throw an exception or return an error message to prevent saving the webform.
throw new \Exception("The required field '{$element['#title']}' is empty.");
}
}
}
$errors = WebformSubmissionForm::validateWebformSubmission($webform_submission);
if ($errors) {
Expand Down

0 comments on commit 260c020

Please sign in to comment.