You are here

public function DeviceListBuilder::submitForm in Responsive Theme Preview 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides DraggableListBuilder::submitForm

File

src/DeviceListBuilder.php, line 71

Class

DeviceListBuilder
Provides a listing of Device entities.

Namespace

Drupal\responsive_preview

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $entities = $form_state
    ->getValue($this->entitiesKey);
  if (!empty($entities)) {
    parent::submitForm($form, $form_state);
    foreach ($entities as $id => $value) {
      if (isset($this->entities[$id]) && $this->entities[$id]
        ->status() !== $value['status']) {
        $this->entities[$id]
          ->setStatus($value['status']);
        $this->entities[$id]
          ->save();
      }
    }
    $this
      ->messenger()
      ->addStatus($this
      ->t('The device settings have been updated.'));
  }
}