Projet

Général

Profil

Paste
Télécharger (1,01 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / addressfield / plugins / format / name-oneline.inc @ f066bdb5

1
<?php
2

    
3
/**
4
 * @file
5
 * Generates a first name + last name format.
6
 */
7

    
8
$plugin = array(
9
  'title' => t('Name (single line)'),
10
  'format callback' => 'addressfield_format_name_oneline_generate',
11
  'type' => 'name',
12
  'weight' => 0,
13
);
14

    
15
/**
16
 * Format callback.
17
 *
18
 * @see CALLBACK_addressfield_format_callback()
19
 */
20
function addressfield_format_name_oneline_generate(&$format, $address) {
21
  $format['name_block'] = array(
22
    '#type' => 'addressfield_container',
23
    '#attributes' => array('class' => array('addressfield-container-inline', 'name-block')),
24
    '#weight' => -100,
25
    // The addressfield is considered empty without a country, hide all fields
26
    // until one is selected.
27
    '#access' => !empty($address['country']),
28
  );
29
  $format['name_block']['name_line'] = array(
30
    '#title' => t('Full name'),
31
    '#tag' => 'div',
32
    '#attributes' => array(
33
      'class' => array('name-block'),
34
      'x-autocompletetype' => 'name',
35
      'autocomplete' => 'name',
36
    ),
37
    '#size' => 30,
38
    '#required' => TRUE,
39
  );
40
}