-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcmo_hacks.module
81 lines (74 loc) · 2.06 KB
/
cmo_hacks.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
// $Id$
/*
* @file
* Hacks for CMO website
*
* This is a custom module for customize certain parts
* of the website.
*/
/**
* Implements hook_help().
*/
function cmo_hacks_help($path, $arg) {
if ($path == 'admin/help#cmo_hacks') {
return t('CMO hacks module.');
}
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function cmo_hacks_form_contact_site_form_alter(&$form, &$form_state) {
// Add a required textfield to collect
// users phone number to the form array.
$form['intro'] = array(
'#title' => t('To contact CMO or leave a message, fill out the form.'),
'#type' => 'item',
);
$form['phone'] = array(
'#title' => t('Phone'),
'#type' => 'textfield',
'#required' => FALSE,
);
$form['condiciones'] = array(
'#title' => t('I agree'),
'#type' => 'checkbox',
'#required' => TRUE,
);
$form['cond_text'] = array(
'#title' => t('NOTE: To continue the process of submission, the user must check a box indicating that you have read and accepted the conditions of the data protection authority. After checking this, you can proceed to send the data to the entity.'),
'#type' => 'item',
);
// Re-sort the form so that we can ensure our phone number field appears
// in the right spot. We're going to do this by building an array of the
// form field keys, then looping through each and setting their weight.
//
// Default fields on the contact form are:
// name (Users Name)
// mail (Users Email Address)
// subject (Email Subject)
// cid (Category select list,
// only visible if multiple contact categories are defined)
// message (Message textarea)
// copy ('Send me a copy' checkbox)
// submit (Submit button)
$order = array(
'intro',
'name',
'mail',
'phone',
'subject',
'cid',
'message',
'copy',
'condiciones',
'cond_text',
'submit'
);
foreach ($order as $key => $field) {
// Set/Reset the field's
// weight to the array key value
// from our order array.
$form[$field]['#weight'] = $key;
}
}