autocomplete_deluxe.api.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * This contains documentation only.
  6. */
  7. /**
  8. * Using the Autocomplete Deluxe element.
  9. *
  10. * When you want to use the Autocomplete Deluxe element, you have to choose
  11. * between two types sources for the suggestion data: Ajax Callbacks or Lists.
  12. * You can set the source type by using the appropriate options:
  13. * - #autocomplete_deluxe_path expects a string with an url, that points to the ajax
  14. * callback. The response should be encoded as json(like for the core
  15. * autocomplete).
  16. * - #autocomplete_options needs an array in the form of an array(similar to #options in core
  17. * for selects or checkboxes): array('a', 'b', 'c') or array(1 => 'a', 2 =>
  18. * 'b', 3 => 'c').
  19. *
  20. * Besides this two, there are three other options, wich autocomplete deluxe
  21. * accepts:
  22. * - #multiple Indicates whether the user may select more than one item. Expects
  23. * TRUE or FALSE, by default it is set to FALSE.
  24. * - #autocomplete_multiple_delimiter If #multiple is TRUE, then you can use
  25. * this option to set a seperator for multiple values. By default a string
  26. * with the follwing content will be used: ', '.
  27. * - #autocomplete_min_length Indicates how many characters must be entered
  28. * until, the suggesion list can be opened. Especially helpfull, when your
  29. * ajax callback returns only valid suggestion for a minimum characters.
  30. * The default is 0.
  31. */
  32. function somefunction() {
  33. switch ($type) {
  34. case 'list':
  35. $element = array(
  36. '#type' => 'autocomplete_deluxe',
  37. '#autocomplete_options' => $options,
  38. '#multiple' => FALSE,
  39. '#autocomplete_min_length' => 0,
  40. );
  41. break;
  42. case 'ajax':
  43. $element = array(
  44. '#type' => 'autocomplete_deluxe',
  45. '#autocomplete_deluxe_path' => url('some_uri', array('absolute' => TRUE)),
  46. '#multiple' => TRUE,
  47. '#autocomplete_min_length' => 1,
  48. '#autocomplete_multiple_delimiter' => '|',
  49. );
  50. break;
  51. }
  52. }