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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
<?php
// Modification total du formulaire de 'contact'
function contact_form_form_contact_site_form_alter(&$form, &$form_state) {
// Ajout d'un attribut au formulaire
$form['#attributes']['novalidate'] = 'novalidate';
// Modification de l'action du formulaire
$form['#action'] = '/#contact'; // J'ai modifié avec /contact et /?uniq_id()#contact
// On degage les champ 'recevoir une copie'
$form['copy']['#type'] = 'hidden';
$form['copy']['#required'] = FALSE;
// On ajoute le champ "captcha"
$form['captcha'] = array(
'#type' => 'captcha',
'#required' => TRUE,
'#prefix' => '<div class="form-footer">',
);
// On ajoute le champ "mentions légales"
$form['accept'] = array(
'#type' => 'checkbox',
'#title' => t('I read the').' <a href="'.getTranslationLink('/node/21').'?noscript" class="colorbox cboxElement">'.t('rule').'</a> '.t('and I accept the privacy policy.'),
'#attributes' => array(
'value' => '1'
),
'#required' => TRUE,
'#prefix' => '<div class="avisos-ct floatRight">',
'#suffix' => '</div></div>',
);
// Ajout d'un attribut placeholder pour les éléments du formulaire et masquage des label
// NOM
$form['name']['#title'] = null;
$form['name']['#attributes'] = array(
'placeholder' => t('LAST NAME AND FIRST NAME'),
'class' => 'floatLeft',
);
// E-MAIL
$form['mail']['#title'] = null;
$form['mail']['#attributes'] = array(
'placeholder' => 'E-MAIL',
'class' => 'floatRight',
);
// SUJET
$form['subject']['#title'] = null;
$form['subject']['#attributes'] = array(
'placeholder' => t('OBJECT'),
);
// MSG
$form['message']['#title'] = null;
$form['message']['#attributes'] = array(
'placeholder' => t('MESSAGE'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('SEND'),
'#ajax' => array(
'callback' => 'contact_form_form_contact_site_form_callback',
'wrapper' => 'form-register-message'
),
'#submit' => array('contact_form_form_contact_site_form_callback'),
);
// Modification de la valeur du bouton submit
//$form['actions']['submit']['#value'] = t('SEND');
}
function contact_form_form_contact_site_form_callback($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_form_contact_site_form_submit($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_submit_function($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_submit($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_form_contact_site_form_submit_function($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_site_form_submit_function($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_form_contact_submit_function($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_form_contact_submit($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
function contact_form_site_form_submit($form, &$form_state) {
echo "ALLO ?!"; return "testccc"; exit('ok');
}
/*
function contact_form_ajax_callback($form, $form_state) {
if (form_get_errors()) {
$form_state['rebuild'] = TRUE;
return $form;
}
$response = contact_form_form_contact_site_form_submit($form, $form_state); // write your form submit logic here.
return $response;
}
/*
function contact_form_submit_function($form, &$form_state) {
global $language;
$params = array('current_conditions' => $data);
$to = 'user@example.com';
$message = drupal_mail('Contact', 'notice', $to, $language, $params, FALSE);
// Only add to the spool if sending was not canceled.
if ($message['send']) {
example_spool_message($message);
}
}
* /
function contact_form_form_contact_site_form_submit($form, &$form_state) {
return "testccc"; exit;
$valid_email = $form_state['values']['email'];
$body[] = 'Email: '.$valid_email.'<br />URL: '.request_uri();
$to = 'rbouillard@economiedenergie.fr';
$params = array(
'body' => $body,
'subject' => 'Contact',
);
drupal_set_message('OOOOOOOOOOOOOOOOOO');
if (drupal_mail('contact_form', 'contact_submit', $to, language_default(), $params, $valid_email, TRUE)) {
drupal_set_message(t('Thanks, we will be in contact with more information soon.'));
}
else {
drupal_set_message(t('There was an error subscribing you. Please try again later'));
}
}
function contact_form_form_contact_mail($key, &$message, $params) {
drupal_set_message('EEEEEEEEEEEEEE');
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8;',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal'
);
foreach ($headers as $key => $value) {
$message['headers'][$key] = $value;
}
$message['subject'] = $params['subject'];
$message['body'] = $params['body'];
}*/ |
Partager