You are here

function hook_webform_help_info in Webform 8.5

Same name and namespace in other branches
  1. 6.x webform.api.php \hook_webform_help_info()

Collect extra webform help from modules.

To help on-boarding new users, there is a robust help system developed. If you would like to add extra webform help, you are free to implement this hook.

Return value

array Extra webform help your module is providing to the users. The return array should be keyed by help ID (a unique machine-name) and each sub array should have the following structure:

  • access: (bool) Whether the current user is granted access to this help. Defaults to TRUE.
  • routes: (array) Array of route names where your help should be displayed.
  • paths: (array) Array of paths where your help should be displayed. You can use any syntax supported by the "path.matcher" service.
  • video_id: (string) Optional video to include in the help message. Allowed values are the keys of WebformHelpManager::videos array.
  • attached: (array) Optional #attached array to attach to your help renderable array.
  • group: (string) Group where your help belongs. Allowed values are the keys of WebformHelpManager::groups array.
  • title: (string) Title of your help
  • content: (array) Renderable array of your help
  • message_id: (string) Optional message ID that will be supplied into 'webform_message' element. You are free to use 'message_*' keys if you want to additionally display a message when your help is displayed. These keys will be supplied into 'webform_message' element. Refer to the docs of this element for their meaning.
  • message_type: (string) Will be supplied into 'webform_message' element.
  • message_close: (bool) Will be supplied into 'webform_message' element.
  • message_storage: (string) Will be supplied into 'webform_message' element.
9 functions implement hook_webform_help_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

webform_access_webform_help_info in modules/webform_access/webform_access.module
Implements hook_webform_help_info().
webform_devel_webform_help_info in modules/webform_devel/webform_devel.module
Implements hook_webform_help_info().
webform_image_select_webform_help_info in modules/webform_image_select/webform_image_select.module
Implements hook_webform_help_info().
webform_options_custom_webform_help_info in modules/webform_options_custom/webform_options_custom.module
Implements hook_webform_help_info().
webform_options_limit_webform_help_info in modules/webform_options_limit/webform_options_limit.module
Implements hook_webform_help_info().

... See full list

1 invocation of hook_webform_help_info()
WebformHelpManager::initHelp in src/WebformHelpManager.php
Initialize help.

File

./webform.api.php, line 539
Hooks related to Webform module.

Code

function hook_webform_help_info() {
  $help = [];
  $help['my_custom_help'] = [
    'access' => \Drupal::currentUser()
      ->hasPermission('my cool permission'),
    'routes' => [
      'my_module.route_where_i_show_this_help',
    ],
    'paths' => [
      '/path/where/*/i-wanna/show-help',
    ],
    'video_id' => 'blocks',
    'attached' => [],
    'group' => 'messages',
    'title' => t('Message: Webform UI Disabled'),
    'content' => t('Please enable the <strong>Webform UI</strong> module if you would like to add easily add and manage elements using a drag-n-drop user interface.'),
    'message_id' => '',
    'message_type' => 'warning',
    'message_close' => TRUE,
    'message_storage' => \Drupal\webform\Element\WebformMessage::STORAGE_STATE,
  ];
  return $help;
}