function webform_reply_to_form_alter in Webform Reply To 6
Same name and namespace in other branches
- 7.2 webform_reply_to.module \webform_reply_to_form_alter()
- 7 webform_reply_to.module \webform_reply_to_form_alter()
Implementation of hook_form_alter().
File
- ./
webform_reply_to.module, line 7
Code
function webform_reply_to_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_email_edit_form') {
$node = $form['node']['#value'];
$email = $node->webform['emails'][$form['eid']['#value']];
$field = 'reply_to';
$default_value = t('No reply-to address');
$title = t('Reply-to address');
$description = t('Any email, select, or hidden form element may be selected as the reply-to email address.');
$form[$field . '_option'] = array(
'#title' => $title,
'#type' => 'radios',
'#default_value' => is_numeric($email[$field]) ? 'component' : (empty($default_value) || $email[$field] != 'default' && isset($email[$field]) ? 'custom' : 'default'),
'#description' => $description,
);
if (!empty($default_value)) {
$form[$field . '_option']['#options']['default'] = $default_value;
}
$form[$field . '_option']['#options']['custom'] = 'custom';
$form[$field . '_option']['#options']['component'] = 'component';
$form[$field . '_custom'] = array(
'#type' => 'textfield',
'#size' => 40,
'#default_value' => !is_numeric($email[$field]) && $email[$field] != 'default' ? $email[$field] : NULL,
'#maxlength' => 255,
);
$options = webform_component_list($node, 'email_address', FALSE);
$form[$field . '_component'] = array(
'#type' => 'select',
'#default_value' => is_numeric($email[$field]) ? $email[$field] : NULL,
'#options' => empty($options) ? array(
'' => t('No available components'),
) : $options,
'#disabled' => empty($options) ? TRUE : FALSE,
'#weight' => 6,
);
$form['#validate'][] = 'webform_reply_to_form_validate';
$form['#submit'][] = 'webform_reply_to_form_submit';
}
}