You are here

public static function RegionWells::submitFormElement in Express 8

Form submission handler.

Parameters

\Drupal\bootstrap\Utility\Element $form: The Element object that comprises the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides SettingBase::submitFormElement

File

themes/contrib/bootstrap/src/Plugin/Setting/Components/Region/RegionWells.php, line 88
Contains \Drupal\bootstrap\Plugin\Setting\Components\Region\RegionWells.

Class

RegionWells
The "region_wells" theme setting.

Namespace

Drupal\bootstrap\Plugin\Setting\Components\Region

Code

public static function submitFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
  $values = $form_state
    ->getValues();

  // Extract the regions from individual dynamic settings.
  $regex = '/^region_well-/';
  $region_wells = [];
  foreach ($values as $key => $value) {
    if (!preg_match($regex, $key)) {
      continue;
    }
    $region_wells[preg_replace($regex, '', $key)] = $value;
    unset($values[$key]);
  }

  // Store the new values.
  $values['region_wells'] = $region_wells;
  $form_state
    ->setValues($values);
}