function newsletter_template_form in Newsletter 7.2
Form callback: create or edit a template.
Parameters
$template: The template object to edit or for a create form an empty template object with only a template type defined.
See also
newsletter_template_form_validate()
newsletter_template_form_submit()
newsletter_template_form_submit_delete()
NewslettertemplateUIController::hook_menu()
File
- modules/
template/ includes/ newsletter_template.admin.inc, line 21 - hook_menu callbacks for admin pages.
Code
function newsletter_template_form($form, &$form_state, $template) {
// Add the default field elements.
$form['mail'] = array(
'#type' => 'textfield',
'#title' => t('E-mail'),
'#default_value' => isset($template->mail) ? $template->mail : '',
'#maxlength' => 255,
'#required' => TRUE,
'#weight' => -5,
);
// Simply use default language for now.
// @todo Support multilingual newsletters.
$form['language'] = array(
'#type' => 'value',
'#value' => LANGUAGE_NONE,
);
// Add the field related form elements.
field_attach_form('newsletter_template', $template, $form, $form_state);
$form['actions'] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'form-actions',
),
),
'#weight' => 400,
);
// We add the form's #submit array to this button along with the actual submit
// handler to preserve any submit handlers added by a form callback_wrapper.
$submit = array();
if (!empty($form['#submit'])) {
$submit += $form['#submit'];
}
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save template'),
'#submit' => $submit + array(
'newsletter_template_form_submit',
),
);
if (!empty($template->hash)) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Unsubscribe'),
'#submit' => $submit + array(
'newsletter_template_form_submit_delete',
),
'#weight' => 45,
);
}
$form['actions']['cancel'] = array(
'#type' => 'link',
'#href' => 'admin/config/media/newsletter/templates',
'#title' => t('Cancel'),
);
// We append the validate handler to #validate in case a form callback_wrapper
// is used to add validate handlers earlier.
$form['#validate'][] = 'newsletter_template_form_validate';
$form_state['newsletter_template'] = $template;
return $form;
}