Hello drupalers, long time I didn't open a new topic, because usually people had solved similar issues before me :)
I have a custom module which alter the core contact form. I read here and there and I was able to build a very simple module with hook_form_contact_site_alter.
then by hook_mail_alter I was able to implement the e-mail sent by the contact form.
Most part of my module came from a tutorial I found on a blog.
I have some custom fields, one of them is a select that call a vocabulary. "field_modello_macchina" is the taxonomy field reference. As first, I build the form
/**
* Implements hook_form_FORM_ID_alter().
*/
function preventivo_form_contact_site_form_alter(&$form, &$form_state) {
$form['modello_macchina'] = array(
'#type' => 'select',
'#empty_option' => t('No specific machine'),
'#title' => t('Machine Model Number'),
'#options' => taxonomy_allowed_values(field_info_field('field_modello_macchina')),
'#description' => t('You can select a Model to receive more information about a machine you are interested in')
);
this code renders the taxonomy term as desired.
Then I build the e-mail sent to the user.
/**
* Implements hook_mail_alter().
*/
function preventivo_mail_alter(&$message) {
if ($message['id'] == 'contact_page_mail'
|| $message['id'] == 'contact_page_copy') {
$message['body'][] = t('Nome') .': '. $message['params']['name'];
.....(other fields)....
$message['body'][] = t('Modello macchina') .': '. $message['params']['modello_macchina'];
}
}
The problem is: when I receive the e-mail it prints only the term id and not the human-readable term name.
Any suggestion on how to render the term name instead of tid?
Thank you very much for any help!