summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJennifer Hodgdon <yahgrp@poplarware.com>2012-10-08 16:45:55 -0700
committerJennifer Hodgdon <yahgrp@poplarware.com>2012-10-08 16:45:55 -0700
commit994b2b3d4b8bf093541d0e61f456110b19fda677 (patch)
tree379087a65e88655b5da2452281cf85c53dd92be7
parent48132ced83a2c5a0447d2d29825cb51ccabe2a3d (diff)
downloadbrdo-994b2b3d4b8bf093541d0e61f456110b19fda677.tar.gz
brdo-994b2b3d4b8bf093541d0e61f456110b19fda677.tar.bz2
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 8f1687736..9b5bb32c9 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.