You are here

private function RulesWebformEventBase::extractcompositeElements in RULES WEBFORM 3.x

Same name and namespace in other branches
  1. 8 src/Event/RulesWebformEventBase.php \Drupal\rules_webform\Event\RulesWebformEventBase::extractcompositeElements()

Extract the information about a webform fields.

This information will be used for fields data definition in the 'WebformFieldsDataDefinition' class.

1 call to RulesWebformEventBase::extractcompositeElements()
RulesWebformEventBase::__construct in src/Event/RulesWebformEventBase.php
Сonstructs the object.

File

src/Event/RulesWebformEventBase.php, line 80

Class

RulesWebformEventBase
Base class for events available in the 'RULES WEBFORM' module.

Namespace

Drupal\rules_webform\Event

Code

private function extractcompositeElements(array $elements, &$fields_definitions) {
  foreach ($elements as $name => $options) {
    if (isset($options['#webform_composite_elements'])) {
      $this
        ->extractcompositeElements($options['#webform_composite_elements'], $fields_definitions);
    }
    else {

      // Exclude wizard pages and buttons from the list of elements.
      if ($options['#type'] != 'webform_wizard_page' && $options['#type'] != "webform_actions") {
        $fields_definitions[$name] = (string) isset($options['#title']) ? $options['#title'] : '';

        // If a user will submit an empty webform which contents composite
        // element, then value of this element can be 'NULL'.
        // Therefore prefill the array of webform_fields to prevent error
        // message appearance.
        $this->webform_fields[$name] = '';
        $this->webform_fields_unchanged[$name] = '';
      }
    }
  }
}