ajax form try setting default values
This commit is contained in:
@@ -272,6 +272,18 @@ function booking_emails_custom_ajax_form($node, &$form_state) {
|
||||
$event->booking_eventname . ' logistics custom ' . $i) . " **Logistics**";
|
||||
}
|
||||
|
||||
// Populate some default values if a selection has already been made
|
||||
if (!isset($form_state['storage']['emailtype'])) {
|
||||
$subject_value = "";
|
||||
$body_value = "";
|
||||
}
|
||||
else {
|
||||
$emailtype = $form_state['storage']['emailtype'];
|
||||
$subject_value = variable_get('booking_email_subject_' . $emailtype, '');
|
||||
$body_value = variable_get('booking_email_' . $emailtype, '');
|
||||
$body_value = isset($body_value['format']) ? $body_value['value'] : $body_value;
|
||||
}
|
||||
|
||||
if(variable_get('booking_enable_html_mail', 0) == 1) {
|
||||
$form_type = 'text_format';
|
||||
$form_format = 'full_html';
|
||||
@@ -301,16 +313,20 @@ function booking_emails_custom_ajax_form($node, &$form_state) {
|
||||
'#suffix' => '</div>'
|
||||
);
|
||||
|
||||
|
||||
|
||||
$form['email-definition']['booking_email_subjectline_custom'] = array (
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Subject line for Custom Email'),
|
||||
'#size' => 150,
|
||||
'#maxlength' => 300,
|
||||
'#value' => $subject_value,
|
||||
//'#value' => isset($form_state['values']['booking_email_subjectline_custom']) ? $form_state['values']['booking_email_subjectline_custom'] : '',
|
||||
);
|
||||
$form['email-definition']['booking_email_body_custom'] = array(
|
||||
'#title' => t('Email text for custom email'),
|
||||
'#description' => t(''),
|
||||
'#description' => t(''),
|
||||
'#value' => $body_value,
|
||||
//'#value' => isset($form_state['values']['booking_email_body_custom']) ? $form_state['values']['booking_email_body_custom'] : '',
|
||||
'#type' => $form_type,
|
||||
'#format' => $form_format,
|
||||
@@ -346,6 +362,8 @@ function booking_emails_custom_ajax_form_callback($form, &$form_state) {
|
||||
//watchdog('booking_debug', 'custom text: <pre>@info</pre>', array('@info' => print_r( $text, true)));
|
||||
// TODO : Figure out what this should be if HTML emails are NOT enabled
|
||||
$form['form']['email-definition']['booking_email_body_custom']['value']['#value'] = $text;
|
||||
|
||||
$form_state['form']['storage']['emailtype'] = $emailtype;
|
||||
}
|
||||
|
||||
//watchdog('booking_debug', 'booking_emails_custom_ajax_form_callback: <pre>@info</pre>', array('@info' => print_r( $form, true)));
|
||||
|
Reference in New Issue
Block a user