Advertisement
Guest User

Untitled

a guest
Sep 19th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /**
  2. * Implements hook_field_widget_form_alter().
  3. */
  4. function MYMODULE_field_widget_form_alter(&$element, $form_state, $context) {
  5. if(!empty($element['#addressfield'])) {
  6. $element['country']['#weight'] = 100;
  7. }
  8. }
  9.  
  10. /**
  11. * Implements hook_ctools_plugin_directory().
  12. */
  13. function MYMODULE_ctools_plugin_directory($module, $plugin) {
  14. if ($module == 'addressfield') {
  15. return 'plugins/' . $plugin;
  16. }
  17. }
  18.  
  19. /**
  20. * Implements hook_ctools_plugin_type().
  21. */
  22. function MYMODULE_ctools_plugin_type() {
  23. $plugins['format'] = array(
  24. 'load themes' => TRUE,
  25. );
  26. return $plugins;
  27. }
  28.  
  29. /**
  30. * @file
  31. * Move country field to the very end.
  32. */
  33.  
  34. $plugin = array(
  35. 'title' => t('Alter addressfield'),
  36. 'format callback' => 'MYMODULE_format_address_alter_country',
  37. 'type' => 'address',
  38. 'weight' => -80,
  39. );
  40.  
  41. /**
  42. * Format callback.
  43. *
  44. * @see CALLBACK_addressfield_format_callback()
  45. */
  46. function MYMODULE_format_address_alter_country(&$format, $address, $context = array()) {
  47. // Move country field to the very end.
  48. $format['country']['#weight'] = 100;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement