function birthdays_field_instance_settings_form in Birthdays 7
Implements hook_field_instance_settings_form().
File
- ./
birthdays.module, line 749 - The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an email on their birthday automatically, and the administrator can receive daily reminders of…
Code
function birthdays_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
// Year settings.
$form['hide_year'] = array(
'#type' => 'radios',
'#title' => t('Year settings'),
'#default_value' => $settings['hide_year'],
'#description' => t('Make entering a year optional, required or forbidden.'),
'#options' => array(
BIRTHDAYS_HIDE_YEAR_NO => t('Require the user to enter a year'),
BIRTHDAYS_HIDE_YEAR_USER => t('Let the user decide, if they want to enter a year'),
BIRTHDAYS_HIDE_YEAR_YES => t('Don\'t allow the user to enter a year'),
),
);
// Email notifications for administrators.
$form['admin_mail'] = array(
'#type' => 'radios',
'#title' => t('Birthday reminder for the administrator'),
'#default_value' => $settings['admin_mail'],
'#description' => t('The site administrator can be reminded of upcoming birthdays via email.'),
'#options' => array(
BIRTHDAYS_ADMIN_MAIL_DISABLED => t('Send <strong>no</strong> reminders'),
BIRTHDAYS_ADMIN_MAIL_DAILY => t('Send <strong>daily</strong> reminders'),
BIRTHDAYS_ADMIN_MAIL_WEEKLY => t('Send <strong>weekly</strong> reminders, on the first day of the week'),
BIRTHDAYS_ADMIN_MAIL_MONTHLY => t('Send <strong>monthly</strong> reminders, on the first day of the month'),
),
);
// Whether the user checkbox is selected.
$user_checked = array(
':input[name="instance[settings][triggers][user]"]' => array(
'checked' => TRUE,
),
);
// Trigger settings.
$form['triggers'] = array(
'#type' => 'fieldset',
'#title' => t('Triggers'),
'#description' => t('You can send an email or execute other actions on birthdays using the trigger module.'),
'user' => array(
'#type' => 'checkbox',
'#title' => t('Allow users to opt-out triggers'),
'#description' => t('Users will see a checkbox for the birthday field, that allows them to opt-out of triggers.'),
'#default_value' => $settings['triggers']['user'],
),
'title' => array(
'#type' => 'textfield',
'#title' => t('Checkbox title'),
'#description' => t('The title to use for opt-out checkbox. Usually this should describe what the trigger does, for example: Send me an email on my brithday.'),
'#default_value' => $settings['triggers']['title'],
'#states' => array(
'visible' => $user_checked,
'required' => $user_checked,
),
'#element_validate' => array(
'_birthdays_required_if_user_checked',
),
),
'description' => array(
'#type' => 'textfield',
'#title' => t('Checkbox description'),
'#description' => t('Optional. The description of the opt-out checkbox.'),
'#default_value' => $settings['triggers']['description'],
'#states' => array(
'visible' => $user_checked,
),
),
);
// Provide information about triggers.
if (module_exists('trigger')) {
$trigger_info = t('Trigger module is enabled. You can !configure_triggers and !actions.', array(
'!configure_triggers' => l('configure triggers', 'admin/structure/trigger/birthdays'),
'!actions' => l('actions', 'admin/config/system/actions'),
));
}
else {
$trigger_info = t('Go to the !module_page and enable the Trigger module', array(
'!module_page' => l('module page', 'admin/modules'),
));
}
$form['triggers']['#description'] .= ' ' . $trigger_info;
return $form;
}