Advertisement
asanchez75

Drupal/snippets/forms/elements

Aug 11th, 2011
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1.  
  2. function custom_theme_registry_alter(&$theme_registry) {
  3. if (!empty($theme_registry['form_element'])) {
  4. $theme_registry['form_element']['function'] = 'custom_form_element';
  5. }
  6. }
  7.  
  8. function custom_form_element($element, $value) {
  9. dsm($element);
  10. if($element['#id'] == 'edit-calendar-goto-datepicker-popup-0'){
  11. //$element['#description'] = 'habla asunción';
  12. }
  13.  
  14.  
  15. // Here, we provide our customized version of the
  16. // theme_form_element function from theme.inc...
  17.  
  18. // This is also used in the installer, pre-database setup.
  19. $t = get_t();
  20.  
  21. $output = '<div class="form-item"';
  22. if (!empty($element['#id'])) {
  23. $output .= ' id="'. $element['#id'] .'-wrapper"';
  24. }
  25. $output .= ">\n";
  26. $required = !empty($element['#required']) ? '<span class="form-required" title="'. $t('This field is required.') .'">*</span>' : '';
  27.  
  28. if (!empty($element['#title'])) {
  29. $title = $element['#title'];
  30. if (!empty($element['#id'])) {
  31. $output .= ' <label for="'. $element['#id'] .'">'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
  32. }
  33. else {
  34. $output .= ' <label>'. $t('!title: !required', array('!title' => filter_xss_admin($title), '!required' => $required)) ."</label>\n";
  35. }
  36. }
  37.  
  38. $output .= " $value\n";
  39. if (!empty($element['#description'])) {
  40. $output .= ' <div class="description">'. $element['#description'] ."</div>\n";
  41. }
  42.  
  43. $output .= "</div>\n";
  44.  
  45. return $output;
  46. }
  47.  
  48.  
  49.  
  50. <!---------------------------------->
  51.  
  52. http://www.lullabot.com/articles/overriding-theme-functions-in-modules
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement