name-full.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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(
  21. 'class' => array('addressfield-container-inline', 'name-block'),
  22. ),
  23. '#weight' => -100,
  24. // The addressfield is considered empty without a country, hide all fields
  25. // until one is selected.
  26. '#access' => !empty($address['country']),
  27. );
  28. $format['name_block']['first_name'] = array(
  29. '#title' => t('First name'),
  30. '#size' => 30,
  31. '#required' => TRUE,
  32. '#attributes' => array(
  33. 'class' => array('first-name'),
  34. 'x-autocompletetype' => 'given-name',
  35. 'autocomplete' => 'given-name',
  36. ),
  37. );
  38. $format['name_block']['last_name'] = array(
  39. '#title' => t('Last name'),
  40. '#size' => 30,
  41. '#required' => TRUE,
  42. '#prefix' => ' ',
  43. '#attributes' => array(
  44. 'class' => array('last-name'),
  45. 'x-autocompletetype' => 'family-name',
  46. 'autocomplete' => 'family-name',
  47. ),
  48. );
  49. }