name-oneline.inc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Generates a first name + last name format.
  5. */
  6. $plugin = array(
  7. 'title' => t('Name (single line)'),
  8. 'format callback' => 'addressfield_format_name_oneline_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_oneline_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. // The addressfield is considered empty without a country, hide all fields
  23. // until one is selected.
  24. '#access' => !empty($address['country']),
  25. );
  26. $format['name_block']['name_line'] = array(
  27. '#title' => t('Full name'),
  28. '#tag' => 'div',
  29. '#attributes' => array(
  30. 'class' => array('name-block'),
  31. 'x-autocompletetype' => 'name',
  32. 'autocomplete' => 'name',
  33. ),
  34. '#size' => 30,
  35. '#required' => TRUE,
  36. );
  37. }