function EntityDisplayFormBase::saveDisplayStatuses

Same name in other branches
  1. 9 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::saveDisplayStatuses()
  2. 10 core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::saveDisplayStatuses()
  3. 11.x core/modules/field_ui/src/Form/EntityDisplayFormBase.php \Drupal\field_ui\Form\EntityDisplayFormBase::saveDisplayStatuses()

Saves the updated display mode statuses.

Parameters

array $display_statuses: An array holding updated form or view mode statuses.

1 call to EntityDisplayFormBase::saveDisplayStatuses()
EntityDisplayFormBase::submitForm in core/modules/field_ui/src/Form/EntityDisplayFormBase.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form stateā€¦

File

core/modules/field_ui/src/Form/EntityDisplayFormBase.php, line 903

Class

EntityDisplayFormBase
Base class for EntityDisplay edit forms.

Namespace

Drupal\field_ui\Form

Code

protected function saveDisplayStatuses($display_statuses) {
    $displays = $this->getDisplays();
    foreach ($displays as $display) {
        // Only update the display if the status is changing.
        $new_status = $display_statuses[$display->get('mode')];
        if ($new_status !== $display->status()) {
            $display->set('status', $new_status);
            $display->save();
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.