Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebformMetadataDate webform elements generate php notices from \Drupal\webform\WebformSubmissionConditionsValidator::checkConditionTrigger #138

Open
patdunlavey opened this issue Apr 13, 2022 · 1 comment

Comments

@patdunlavey
Copy link
Collaborator

We are seeing a notice that is filling up watchdog, and think I traced it to the fact that the WebformMetadataDate elements are not defined as composite webform elements. The notice looks like this:

Message Notice: Array to string conversion in Drupal\webform\WebformSubmissionConditionsValidator->checkConditionTrigger() (line 821 of /var/www/html/web/modules/contrib/webform/src/WebformSubmissionConditionsValidator.php)

The $element_value being checked consists of an array like this:

 array:4 [
    "date_type" => "date_free"
    "date_from" => ""
    "date_to" => ""
    "date_free" => "2002-06-08"
  ]

...whereas I think it's supposed to consist of the value of the date_type: "date_free" (in this example).

The reason this is an array rather than the value of date_type, is because in the place where it calls $element_plugin->getElementSelectorInputValue to get the value from the element, with the selector (in our example) :input[name="obj_created_date[items][0][_item_][date_type]"] , it checks to see if the webform element is composite and if so, drills into the element to get the value. However, since the WebformMetadataDate element is not defined as composite, it returns the raw value of the field, which is the array.

After discussion with @DiegoPino on Slack, we agreed that, rather than perform a major refactor to the MetadataDate elements to be composite webform elements, we would instead override the \Drupal\webform\Plugin\WebformElementBase::getElementSelectorInputValue method in \Drupal\webform_strawberryfield\Plugin\WebformElement\MetadataDateBase.

A PR for this will be forthcoming from me!

@patdunlavey
Copy link
Collaborator Author

PR created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant