You are here

public static function WebformLikert::afterBuild in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Element/WebformLikert.php \Drupal\webform\Element\WebformLikert::afterBuild()

Performs the after_build callback.

File

src/Element/WebformLikert.php, line 273

Class

WebformLikert
Provides a webform element for a likert scale.

Namespace

Drupal\webform\Element

Code

public static function afterBuild(array $element, FormStateInterface $form_state) {
  if ($form_state
    ->isProcessingInput()) {

    // Likert elements contain a table which uses 'item' form elements to
    // display the questions. These 'item' elements provide undesired data to
    // the $form_state values. Set the value in $form_state again to overwrite
    // the undesired item values.
    // @see https://www.drupal.org/project/webform/issues/3090007
    $form_state
      ->setValueForElement($element, $element['#value']);
  }
  return $element;
}