I have added on field in my site wide contact form through this code :
function cstm_form_contact_site_form_alter(&$form, &$form_state, $form_id) {
// Add a phone number field to the contact form.
$form['phone'] = array(
'#type' => 'textfield',
'#maxlength' => 20,
'#title' => t('Your phone'),
);
// Define the order of the top level elements on the form (include those from contact_site_form().
$order = array('name', 'mail', 'phone', 'subject', 'cid', 'message', 'copy', 'actions');
// Order the elements by changing their #weight property.
foreach($order as $key => $field) {
$form[$field]['#weight'] = $key;
}
}
Now Do I need to add drupal_mail
with phone number into it or Drupal will consider it automatically ? As I am new to drupal I don't know much about it.
drupal_mail
? Can I append my phone number in Body part of message like this$message['body'][] = t('Phone') .': '. $message['params']['phone'];
? Is it good practice to do in this way ?