Theme a form button / Admin Form Buttons auslassen


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2.  * Theme a form button.
  3.  *
  4.  * @ingroup themeable
  5.  */
  6.  
  7. function mytheme_button($element) {
  8. // Make sure not to overwrite classes.
  9. if (isset($element['#attributes']['class'])) {
  10. $element['#attributes']['class'] = 'Button form-' . $element['#button_type'] . ' ' . $element['#attributes']['class'];
  11. }
  12. else {
  13. $element['#attributes']['class'] = 'Button form-' . $element['#button_type'];
  14. }
  15.  
  16. // Skip admin pages due to some issues with ajax not being able to find buttons.
  17. if (arg(0) == 'admin') {
  18. return '<input type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name'] .'" ') .'id="'. $element['#id'] .'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']) ." />\n";
  19. }
  20.  
  21. return '<button type="submit" ' . (empty($element['#name']) ? '' : 'name="' . $element['#name']
  22. . '" ') . 'id="' . $element['#id'] . '" value="' . check_plain($element['#value']) . '" ' . drupal_attributes($element['#attributes']) . '>'
  23. . '<span class="btn">'
  24. . '<span class="l"></span>'
  25. . '<span class="r"></span>'
  26. . '<span class="t">' . check_plain($element['#value']) . '</span>'
  27. . '</span></button>';
  28. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.