You are here

function callback_checklistapi_checklist_items in Checklist API 8

Define the checklist items for a given checklist.

Declared in hook_checklistapi_checklist_info().

Parameters

mixed $argument: Any number of arguments may be passed from a checklist definition via its #callback_arguments array.

Return value

array An array of arrays representing groups of items, to be presented as vertical tabs. Each group is keyed by an arbitrary identifier, unique in the scope of the checklist. The corresponding multimensional array describing the group may contain the following key-value pairs:

  • #title: The title of the group, used as the vertical tab label.
  • #description: (optional) A description of the group.
  • #weight: (optional) A floating point number used to sort the list of groups before being output. Lower numbers appear before higher numbers.
  • Any number of arrays representing checklist items. Each item is keyed by an arbitrary identifier, unique in the scope of the checklist. The corresponding multimensional array describing the item may contain the following key-value pairs:

    • #title: The title of the item.
    • #description: (optional) A description of the item, for display beneath the title.
    • #default_value: (optional) The default checked state of the item--TRUE for checked or FALSE for unchecked. Defaults to FALSE. This is useful for automatically checking items that can be programmatically tested (e.g., a module is installed or a configuration setting has a certain value).
    • #weight: (optional) A floating point number used to sort the list of items before being output. Lower numbers appear before higher numbers.
    • Any number of arrays representing links. Each link is keyed by an arbitrary unique identifier. The corresponding multimensional array describing the link may contain the following key-value pairs:

      • #text: The link text.
      • #url: The link url as a \Drupal\Core\Url object.
      • #weight: (optional) A floating point number used to sort the list of items before being output. Lower numbers appear before higher numbers.

See also

hook_checklistapi_checklist_info()

checklistapiexample_checklistapi_checklist_items()

1 string reference to 'callback_checklistapi_checklist_items'
hook_checklistapi_checklist_info in ./checklistapi.api.php
Define all checklists provided by the module.

File

./checklistapi.api.php, line 111
Hooks provided by the Checklist API module.

Code

function callback_checklistapi_checklist_items($argument) {
  return [
    'example_group' => [
      '#title' => t('Example group'),
      '#description' => t('<p>Here are some example items.</p>'),
      'example_item_1' => [
        '#title' => t('Example item 1'),
        'example_link' => [
          '#text' => t('Example.com'),
          '#url' => \Drupal\Core\Url::fromUri('http://www.example.com/'),
        ],
      ],
      'example_item_2' => [
        '#title' => t('Example item 2'),
      ],
    ],
  ];
}