You are here

function hook_captcha_placement_map in CAPTCHA 8

Implements hook_captcha_placement_map().

=== Hook into CAPTCHA placement === The CAPTCHA module attempts to place the CAPTCHA element in an appropriate spot at the bottom of the targeted form, but this automatic detection may be insufficient for complex forms. The hook_captcha_placement_map hook allows to define the placement of the CAPTCHA element as desired. The hook should return an array, mapping form IDs to placement arrays, which are associative arrays with the following fields: 'path': path (array of path items) of the form's container element in which the CAPTCHA element should be inserted. 'key': the key of the element before which the CAPTCHA element should be inserted. If the field 'key' is undefined or NULL, the CAPTCHA will just be appended in the container. 'weight': if 'key' is not NULL: should be the weight of the element defined by 'key'. If 'key' is NULL and weight is not NULL/unset: set the weight property of the CAPTCHA element to this value. For example: This will place the CAPTCHA element in the 'my_fancy_form' form inside the container $form['items']['buttons'], just before the element $form['items']['buttons']['sacebutton']. in the 'another_form' form at the toplevel of the form, with a weight 34.

1 invocation of hook_captcha_placement_map()
_captcha_get_captcha_placement in ./captcha.inc
Helper function to get placement information for a given form_id.

File

./captcha.api.php, line 186
Hooks for the captcha module.

Code

function hook_captcha_placement_map() {
  return [
    'my_fancy_form' => [
      'path' => [
        'items',
        'buttons',
      ],
      'key' => 'savebutton',
    ],
    'another_form' => [
      'path' => [],
      'weight' => 34,
    ],
  ];
}