elements.theme.inc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /**
  3. * @file
  4. * The theme include file for the elements module.
  5. *
  6. * Contains the theme functions for all the elements module elements.
  7. */
  8. /**
  9. * Returns HTML for an emailfield form element.
  10. *
  11. * @param $variables
  12. * An associative array containing:
  13. * - element: An associative array containing the properties of the element.
  14. * Properties used: #title, #value, #description, #size, #maxlength,
  15. * #placeholder, #required, #attributes, #autocomplete_path.
  16. *
  17. * @ingroup themeable
  18. */
  19. function theme_emailfield($variables) {
  20. $element = $variables['element'];
  21. $element['#attributes']['type'] = 'email';
  22. element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
  23. _form_set_class($element, array('form-text', 'form-email'));
  24. $extra = elements_add_autocomplete($element);
  25. $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  26. return $output . $extra;
  27. }
  28. /**
  29. * Returns HTML for a searchfield form element.
  30. *
  31. * @param $variables
  32. * An associative array containing:
  33. * - element: An associative array containing the properties of the element.
  34. * Properties used: #title, #value, #description, #size, #maxlength,
  35. * #placeholder, #required, #attributes, #autocomplete_path.
  36. *
  37. * @ingroup themeable
  38. */
  39. function theme_searchfield($variables) {
  40. $element = $variables['element'];
  41. $element['#attributes']['type'] = 'search';
  42. element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
  43. _form_set_class($element, array('form-text', 'form-search'));
  44. $extra = elements_add_autocomplete($element);
  45. $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  46. return $output . $extra;
  47. }
  48. /**
  49. * Returns HTML for a telfield form element.
  50. *
  51. * @param $variables
  52. * An associative array containing:
  53. * - element: An associative array containing the properties of the element.
  54. * Properties used: #title, #value, #description, #size, #maxlength,
  55. * #placeholder, #required, #attributes.
  56. *
  57. * @ingroup themeable
  58. */
  59. function theme_telfield($variables) {
  60. $element = $variables['element'];
  61. $element['#attributes']['type'] = 'tel';
  62. element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
  63. _form_set_class($element, array('form-text', 'form-tel'));
  64. $extra = elements_add_autocomplete($element);
  65. $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  66. return $output . $extra;
  67. }
  68. /**
  69. * Returns HTML for an urlfield form element.
  70. *
  71. * @param $variables
  72. * An associative array containing:
  73. * - element: An associative array containing the properties of the element.
  74. * Properties used: #title, #value, #description, #size, #maxlength,
  75. * #placeholder, #required, #attributes, #autocomplete_path.
  76. *
  77. * @ingroup themeable
  78. */
  79. function theme_urlfield($variables) {
  80. $element = $variables['element'];
  81. $element['#attributes']['type'] = 'url';
  82. element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
  83. _form_set_class($element, array('form-text', 'form-url'));
  84. $extra = elements_add_autocomplete($element);
  85. $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  86. return $output . $extra;
  87. }
  88. /**
  89. * Returns HTML for a numberfield form element.
  90. *
  91. * @param $variables
  92. * An associative array containing:
  93. * - element: An associative array containing the properties of the element.
  94. * Properties used: #title, #value, #description, #min, #max, #placeholder,
  95. * #required, #attributes, #step.
  96. *
  97. * @ingroup themeable
  98. */
  99. function theme_numberfield($variables) {
  100. $element = $variables['element'];
  101. $element['#attributes']['type'] = 'number';
  102. element_set_attributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder'));
  103. _form_set_class($element, array('form-text', 'form-number'));
  104. $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  105. return $output;
  106. }
  107. /**
  108. * Returns HTML for a rangefield form element.
  109. *
  110. * @param $variables
  111. * An associative array containing:
  112. * - element: An associative array containing the properties of the element.
  113. * Properties used: #title, #value, #description, #min, #max, #attributes,
  114. * #step.
  115. *
  116. * @ingroup themeable
  117. */
  118. function theme_rangefield($variables) {
  119. $element = $variables['element'];
  120. $element['#attributes']['type'] = 'range';
  121. element_set_attributes($element, array('id', 'name', 'value', 'step', 'min', 'max'));
  122. _form_set_class($element, array('form-text', 'form-range'));
  123. $output = '<input' . drupal_attributes($element['#attributes']) . ' />';
  124. return $output;
  125. }