function LayoutForm::handleFormElementsVisibility

Handles visibility of the form elements based on the edit mode status.

Parameters

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

bool $edit_mode_enabled: Boolean indicating whether the Navigation layout edit mode is enabled.

File

core/modules/navigation/src/Form/LayoutForm.php, line 147

Class

LayoutForm
Defines a form for configuring navigation blocks.

Namespace

Drupal\navigation\Form

Code

protected function handleFormElementsVisibility(array &$form, bool $edit_mode_enabled = TRUE) : array {
    // Edit mode elements are visible only in edit mode.
    $form['actions']['submit']['#access'] = $form['actions']['discard_changes']['#access'] = $form['actions']['preview_toggle']['#access'] = $form['actions']['preview_toggle']['toggle_content_preview']['#access'] = $form['layout_builder']['#access'] = $edit_mode_enabled;
    // Edit mode flag element is only visible when edit mode is disabled.
    $form['actions']['enable_edit_mode']['#access'] = !$edit_mode_enabled;
    return $form;
}

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