public function SimpleMobileMenuForm::buildForm in Simple Mobile Menu 8
Same name and namespace in other branches
- 8.2 src/Form/SimpleMobileMenuForm.php \Drupal\simple_mobile_menu\Form\SimpleMobileMenuForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/Form/ SimpleMobileMenuForm.php, line 32 
Class
- SimpleMobileMenuForm
- Provides a simple mobile menu settings form.
Namespace
Drupal\simple_mobile_menu\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
  $simple_mobile_menu_config = $this
    ->config('simple_mobile_menu.settings');
  // Get list of current menu Types.
  $simple_menu = \Drupal::service('entity.manager')
    ->getStorage('menu')
    ->loadMultiple();
  $options = [];
  foreach ($simple_menu as $menus) {
    $options[$menus
      ->id()] = $menus
      ->label();
  }
  $form['menu_name'] = [
    '#type' => 'select',
    '#options' => $options,
    '#description' => t('<br/><em><b>Note:</b> To override the default css of simple mobile menu, please add below classes in your theme styles.css file and assign font, color etc. properties. <br/><b> main_menu, sub_menu </b></em>'),
    '#default_value' => $simple_mobile_menu_config
      ->get('menu_name'),
    '#title' => t('List of Available Menus'),
  ];
  return parent::buildForm($form, $form_state);
  // Leave an empty line here.
}