function shortcut_set_customize

Form callback: builds the form for customizing shortcut sets.

Parameters

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

$form_state: An associative array containing the current state of the form.

$shortcut_set Drupal\shortcut\Plugin\Core\Entity\Shortcut: An object representing the shortcut set which is being edited.

Return value

An array representing the form definition.

See also

shortcut_set_customize_submit()

Related topics

1 string reference to 'shortcut_set_customize'
shortcut_menu in drupal/core/modules/shortcut/shortcut.module
Implements hook_menu().

File

drupal/core/modules/shortcut/shortcut.admin.inc, line 197
Administrative page callbacks for the shortcut module.

Code

function shortcut_set_customize($form, &$form_state, $shortcut_set) {
  $form['#shortcut_set_name'] = $shortcut_set
    ->id();
  $form['shortcuts'] = array(
    '#tree' => TRUE,
    '#weight' => -20,
    'links' => array(),
  );
  foreach ($shortcut_set->links as $uuid => $link) {
    $mlid = $link['mlid'];
    $form['shortcuts']['links'][$mlid]['name']['#markup'] = l($link['link_title'], $link['link_path']);
    $form['shortcuts']['links'][$mlid]['weight'] = array(
      '#type' => 'weight',
      '#title' => t('Weight for @title', array(
        '@title' => $link['link_title'],
      )),
      '#title_display' => 'invisible',
      '#delta' => 50,
      '#default_value' => $link['weight'],
      '#attributes' => array(
        'class' => array(
          'shortcut-weight',
        ),
      ),
    );
    $links['edit'] = array(
      'title' => t('Edit'),
      'href' => "admin/config/user-interface/shortcut/link/{$mlid}",
    );
    $links['delete'] = array(
      'title' => t('Delete'),
      'href' => "admin/config/user-interface/shortcut/link/{$mlid}/delete",
    );
    $form['shortcuts']['links'][$mlid]['operations'] = array(
      '#type' => 'operations',
      '#links' => $links,
    );
  }
  $form['actions'] = array(
    '#type' => 'actions',
    '#access' => !empty($shortcut_set->links),
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save changes'),
  );
  return $form;
}