public static function WebformComputedBase::validateWebformComputed in Webform 8.5
Same name in this branch
- 8.5 src/Element/WebformComputedBase.php \Drupal\webform\Element\WebformComputedBase::validateWebformComputed()
- 8.5 src/Plugin/WebformElement/WebformComputedBase.php \Drupal\webform\Plugin\WebformElement\WebformComputedBase::validateWebformComputed()
Same name and namespace in other branches
- 6.x src/Element/WebformComputedBase.php \Drupal\webform\Element\WebformComputedBase::validateWebformComputed()
Validates an computed element.
File
- src/
Element/ WebformComputedBase.php, line 162
Class
- WebformComputedBase
- Provides a base class for 'webform_computed' elements.
Namespace
Drupal\webform\ElementCode
public static function validateWebformComputed(&$element, FormStateInterface $form_state, &$complete_form) {
// Make sure the form's state value uses the computed value and not the
// raw #value. This ensures conditional handlers are triggered using
// the accurate computed value.
$webform_submission = static::getWebformSubmission($element, $form_state, $complete_form);
if ($webform_submission) {
$value = static::computeValue($element, $webform_submission);
$form_state
->setValueForElement($element['value'], NULL);
$form_state
->setValueForElement($element['hidden'], NULL);
$form_state
->setValueForElement($element, $value);
}
}