diff --git a/core/includes/form.inc b/core/includes/form.inc index 665a9e6..b1934af 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3709,6 +3709,36 @@ function theme_vertical_tabs($variables) { * The form element to process. Properties used: * - #autocomplete_path: A system path to be used as callback URL by the * autocomplete JavaScript library. + * + * * Here is an example of how to use an autocompletion callback: + * + * Autocomplete callback functions tend to have a bug wherein forward-slash + * characters cause an error. + * + * If the request has a '/' in the text, then the menu system will split it + * into multiple arguments and recover the intended $keywords. + * + * If your autocomplete path in the menu is 'mymodule_autocomplete' and in + * your form you have: + * + * @code + * '#autocomplete_path' => 'mymodule_autocomplete/' . $some_key . '/' . $some_id, + * @endcode + * + * and the user types in "keywords" so the full path called is: + * + * 'mymodule_autocomplete/$some_key/$some_id/keywords'. + * + * @code + * function mymodule_autocomplete_callback($arg1, $arg2, $keywords) { + * $args = func_get_args(); + * array_shift($args); + * array_shift($args); + * $keywords = implode('/', $args); + * + * // Your code here. + * } + * @endcode */ function form_process_autocomplete($element, &$form_state) { if (!empty($element['#autocomplete_path']) && drupal_valid_path($element['#autocomplete_path'])) {