summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Hodgdon2012-10-08 23:45:55 (GMT)
committer Jennifer Hodgdon2012-10-08 23:45:55 (GMT)
commit994b2b3d4b8bf093541d0e61f456110b19fda677 (patch)
tree379087a65e88655b5da2452281cf85c53dd92be7
parent48132ced83a2c5a0447d2d29825cb51ccabe2a3d (diff)
Issue #1492378 by tim.plunkett, scottalan, xjm: Document how to use slashes in autocompletes
-rw-r--r--includes/form.inc29
1 files changed, 29 insertions, 0 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 8f16877..9b5bb32 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.