Commit 87c647b0 authored by catch's avatar catch

Issue #1492378 by scottalan: Document proper use of #autocomplete_path() for slashes.

parent 945e7605
......@@ -3732,6 +3732,35 @@ function theme_vertical_tabs($variables) {
/**
* Adds autocomplete functionality to elements with a valid #autocomplete_path.
*
* 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
* The form element to process. Properties used:
* - #autocomplete_path: A system path to be used as callback URL by the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment