function ajax_register_add_redirect_settings in Ajax Login/Register 7.4
Adds standard redirect options to admin form for different form types.
1 call to ajax_register_add_redirect_settings()
- ajax_register_admin_form in ./
ajax_register.admin.inc - Administrative settings form.
File
- ./
ajax_register.admin.inc, line 100 - Provides form with AJAX REGISTER module settings.
Code
function ajax_register_add_redirect_settings(&$form, $form_type) {
$form[$form_type] = array(
'#type' => 'fieldset',
'#title' => t(drupal_ucfirst($form_type) . ' Form'),
);
// Provide a list of redirect behaviors.
$redirect_behaviors = array(
'default' => t('Default'),
'refresh' => t('Refresh'),
'custom' => t('Custom'),
'none' => t('No Redirect'),
);
// Only provide the no redirect behavior for non-login forms.
if ($form_type == 'login') {
array_pop($redirect_behaviors);
}
$redirect = variable_get('ajax_register_' . $form_type . '_redirect_behavior', 'default');
$form[$form_type]['ajax_register_' . $form_type . '_redirect_behavior'] = array(
'#form_type' => $form_type,
'#type' => 'select',
'#title' => t('Redirect Behavior'),
'#options' => $redirect_behaviors,
'#default_value' => $redirect,
);
$form[$form_type]['ajax_register_' . $form_type . '_redirect_url'] = array(
'#type' => 'textfield',
'#title' => t('Redirect URL'),
'#description' => t('Enter the URL that the user will be redirected to after a successful login.'),
'#default_value' => variable_get('ajax_register_' . $form_type . '_redirect_url', ''),
'#states' => array(
// Hide the settings when the redirect checkbox is has wrong value.
'visible' => array(
':input[name="ajax_register_' . $form_type . '_redirect_behavior"]' => array(
'value' => 'custom',
),
),
'required' => array(
':input[name="ajax_register_' . $form_type . '_redirect_behavior"]' => array(
'value' => 'custom',
),
),
),
);
// Provide descriptions for redirect behaviors.
$redirect_descriptions = array(
t('Default') => t('After successful submission of the form, the redirect path is handled by Drupal and will redirect the user to whatever the $form_state["redirect"] variable is set to. NOTE: This option may be required if there are additional modules or features that handle the redirect logic.'),
t('Refresh') => t('After successful submission of the form, the page will be refreshed.'),
t('Custom') => t('After successful submission of the form, users will be redirected to this manually set custom URL.'),
t('No Redirect') => t('After successful submission of the form, the modal window will simply close and not redirect the user to any location.'),
);
// Only provide the no redirect behavior for non-login forms.
if ($form_type == 'login') {
array_pop($redirect_descriptions);
}
// Theme descriptions as an item list.
$items = array();
foreach ($redirect_descriptions as $title => $description) {
$items[] = '<strong>' . $title . '</strong> - ' . $description;
}
$redirect_description = theme('item_list', array(
'items' => $items,
));
$form[$form_type]['ajax_register_' . $form_type . '_redirect_behavior']['#description'] = $redirect_description;
}