1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Generates a first name + last name format.
|
6
|
*/
|
7
|
|
8
|
$plugin = array(
|
9
|
'title' => t('Name (First name, Last name)'),
|
10
|
'format callback' => 'addressfield_format_name_full_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_full_generate(&$format, $address) {
|
21
|
$format['name_block'] = array(
|
22
|
'#type' => 'addressfield_container',
|
23
|
'#attributes' => array(
|
24
|
'class' => array('addressfield-container-inline', 'name-block'),
|
25
|
),
|
26
|
'#weight' => -100,
|
27
|
// The addressfield is considered empty without a country, hide all fields
|
28
|
// until one is selected.
|
29
|
'#access' => !empty($address['country']),
|
30
|
);
|
31
|
$format['name_block']['first_name'] = array(
|
32
|
'#title' => t('First name'),
|
33
|
'#size' => 30,
|
34
|
'#required' => TRUE,
|
35
|
'#attributes' => array(
|
36
|
'class' => array('first-name'),
|
37
|
'x-autocompletetype' => 'given-name',
|
38
|
'autocomplete' => 'given-name',
|
39
|
),
|
40
|
);
|
41
|
$format['name_block']['last_name'] = array(
|
42
|
'#title' => t('Last name'),
|
43
|
'#size' => 30,
|
44
|
'#required' => TRUE,
|
45
|
'#prefix' => ' ',
|
46
|
'#attributes' => array(
|
47
|
'class' => array('last-name'),
|
48
|
'x-autocompletetype' => 'family-name',
|
49
|
'autocomplete' => 'family-name',
|
50
|
),
|
51
|
);
|
52
|
}
|