name-full.inc 986 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * @file
  4. * Generates a first name + last name format.
  5. */
  6. $plugin = array(
  7. 'title' => t('Name (First name, Last name)'),
  8. 'format callback' => 'addressfield_format_name_full_generate',
  9. 'type' => 'name',
  10. 'weight' => 0,
  11. );
  12. /**
  13. * Format callback.
  14. *
  15. * @see CALLBACK_addressfield_format_callback()
  16. */
  17. function addressfield_format_name_full_generate(&$format, $address) {
  18. $format['name_block'] = array(
  19. '#type' => 'addressfield_container',
  20. '#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
  21. '#weight' => -100,
  22. );
  23. $format['name_block']['first_name'] = array(
  24. '#title' => t('First name'),
  25. '#size' => 30,
  26. '#required' => TRUE,
  27. '#attributes' => array('class' => array('first-name')),
  28. );
  29. $format['name_block']['last_name'] = array(
  30. '#title' => t('Last name'),
  31. '#size' => 30,
  32. '#required' => TRUE,
  33. '#prefix' => ' ',
  34. '#attributes' => array('class' => array('last-name')),
  35. );
  36. }