You are here

function uikit_components_form_block_form_alter in UIkit Components 8

Same name and namespace in other branches
  1. 8.3 includes/alter.inc \uikit_components_form_block_form_alter()
  2. 8.2 includes/alter.inc \uikit_components_form_block_form_alter()

Implements hook_form_BASE_FORM_ID_alter().

File

./uikit_components.module, line 96
UIkit Components.

Code

function uikit_components_form_block_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $block = $form_state
    ->getFormObject()
    ->getEntity();
  $region = $block
    ->getRegion();
  if ($region == 'navbar') {

    // Add navbar alignment setting to navbar blocks.
    $form['uikit_navbar_alignment'] = [
      '#type' => 'select',
      '#title' => t('UIkit navbar alignment'),
      '#default_value' => $block
        ->getThirdPartySetting('uikit_components', 'uikit_navbar_alignment'),
      '#options' => [
        0 => t('Left'),
        1 => t('Right'),
      ],
      '#description' => t('Select the alignment of this menu in the UIkit navbar region.'),
      '#weight' => 0,
    ];

    // Add a form entity builder.
    $form['#entity_builders'][] = 'uikit_components_form_block_form_builder';
  }
}