diff --git a/includes/form.inc b/includes/form.inc index 8f1687736363f2225910c24d00a28e67e92a770e..9b5bb32c9ab43b3061541b5a5356857f64ce0fe7 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -3659,6 +3659,35 @@ function form_pre_render_fieldset($element) { /** * Creates a group formatted as vertical tabs. * + * Note that autocomplete callbacks should include special handling as the + * user's input may contain forward slashes. If the user-submitted string has a + * '/' in the text that is sent in the autocomplete request, the menu system + * will split the text and pass it to the callback as multiple arguments. + * + * Suppose your autocomplete path in the menu system is 'mymodule_autocomplete.' + * In your form you have: + * @code + * '#autocomplete_path' => 'mymodule_autocomplete/' . $some_key . '/' . $some_id, + * @endcode + * The user types in "keywords" so the full path called is: + * 'mymodule_autocomplete/$some_key/$some_id/keywords' + * + * You should include code similar to the following to handle slashes in the + * input: + * @code + * function mymodule_autocomplete_callback($arg1, $arg2, $keywords) { + * $args = func_get_args(); + * // We need to remove $arg1 and $arg2 from the beginning of the array so we + * // are left with the keywords. + * array_shift($args); + * array_shift($args); + * // We store the user's original input in $keywords, including any slashes. + * $keywords = implode('/', $args); + * + * // Your code here. + * } + * @endcode + * * @param $element * An associative array containing the properties and children of the * fieldset.