Skip to content
Snippets Groups Projects

Allow uploading files during submission of a webform.

1 unresolved thread

Closes #3503564

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
94 94 return $this->validationErrors;
95 95 }
96 96
97 /**
98 * Returns the validation error that corresponds to the given element.
99 *
100 * @param string|null $elementId
101 * The ID of the Webform element for which to return the validation error,
102 * or NULL to return the general validation error.
103 *
104 * @return \Drupal\graphql_webform\Model\WebformSubmissionValidationError
105 * The validation error. If no error exists for the given element ID yet, an
106 * empty error object is returned.
107 */
108 public function getValidationError(?string $elementId): WebformSubmissionValidationError {
109 return $this->validationErrors[$elementId] ?? new WebformSubmissionValidationError([], $elementId);
  • Comment on lines +108 to +109

    The name getValidationError might be worth reconsidering, since:

    1. We already have getValidationErrors which creates similar naming
    2. The current name doesn't clearly reflect its dual behavior:
      • Sometimes it retrieves an error from state
      • Sometimes it creates a new (unpersisted) error

    This could potentially mislead developers into assuming an error existed in state when getValidationError actually created a fresh one.

  • Great suggestion! I have renamed the method to getOrCreateValidationError().

    This also made me realize we have no easy way to check if a validation error exists for a given element. I added function hasValidationError(?string $elementId): bool for this to complete the API.

  • Please register or sign in to reply
  • Pieter Frenssen added 2 commits

    added 2 commits

    • 4244f61e - Rename the method to get or create a validation error so that it is clear what is returned.
    • 9735f787 - Add a method to check if a validation error exists for a given element.

    Compare with previous version

  • Please register or sign in to reply
    Loading