diff --git a/booking.emails_admin.inc b/booking.emails_admin.inc index f79be45..870ba00 100644 --- a/booking.emails_admin.inc +++ b/booking.emails_admin.inc @@ -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' => '' ); + + $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:
@info
', 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:
@info
', array('@info' => print_r( $form, true)));