function availability_calendar_booking_formlet_field_settings_form in Availability Calendars 7.3
Same name and namespace in other branches
- 7.5 booking_formlet/availability_calendar_booking_formlet.module \availability_calendar_booking_formlet_field_settings_form()
- 7.4 booking_formlet/availability_calendar_booking_formlet.module \availability_calendar_booking_formlet_field_settings_form()
Implements hook_field_settings_form(). @link http://api.drupal.org/api/drupal/modules--field_ui--field_ui.api.php/fun...
File
- booking_formlet/
availability_calendar_booking_formlet.module, line 66 - Availability Calendar booking formlet module. This submdule of the Availability Calendar module defines a field that shows a small booking form that interacts with a calendar field. The form only has an arraival and departure date field and a submit…
Code
function availability_calendar_booking_formlet_field_settings_form($field, $instance, $has_data) {
module_load_include('inc', 'availability_calendar', 'availability_calendar');
$settings = $field['settings'];
$form = array();
$form['url_2_continue'] = array(
'#type' => 'markup',
'#markup' => '<fieldset class="form-wrapper"><legend><span class="fieldset-legend">' . t("URL to continue the booking") . '</span></legend><div class="fieldset-wrapper">',
'#weight' => 10,
);
$form['define_per_language'] = array(
'#type' => 'checkbox',
'#title' => t('Define the URL to continue the booking per language'),
'#description' => t("Webforms are not language aware. Check this option if you want to continue the booking with a different URL (webform) per language."),
'#default_value' => $settings['define_per_language'],
'#required' => FALSE,
'#weight' => 11,
);
$form['post_url'] = array(
'#type' => 'item',
'#description' => t("These URL's typically point to a webform.") . ' ' . t("Do not start internal URL's with a '/'. You can use the system URL, it wil be replaced by its alias. See the help for more instructions about setting up the target page or webform."),
'#suffix' => '</div></fieldset>',
'#weight' => 12,
);
$form['post_url'][LANGUAGE_NONE] = array(
'#type' => 'textfield',
'#title' => t('All languages') . '/' . t('Language neutral'),
'#default_value' => isset($settings['post_url'][LANGUAGE_NONE]) ? $settings['post_url'][LANGUAGE_NONE] : (is_array($settings['post_url']) ? reset($settings['post_url']) : ''),
'#required' => FALSE,
'#states' => array(
'visible' => array(
':input[name="field[settings][define_per_language]"]' => array(
'checked' => FALSE,
),
),
),
);
$language_list = function_exists('locale_language_list') ? locale_language_list() : array_combine(array_keys($settings['post_url']), array_keys($settings['post_url']));
foreach ($language_list as $language_code => $language_name) {
$form['post_url'][$language_code] = array(
array(
'#type' => 'textfield',
'#title' => $language_name,
'#default_value' => isset($settings['post_url'][$language_code]) ? $settings['post_url'][$language_code] : $settings['post_url'][LANGUAGE_NONE],
'#required' => FALSE,
'#states' => array(
'visible' => array(
':input[name="field[settings][define_per_language]"]' => array(
'checked' => TRUE,
),
),
),
),
);
}
$form['booked_state'] = array(
'#type' => 'select',
'#title' => t('Change state to'),
'#description' => t("The state to change the calendar to after the user has selected the arrival and departure dates. Note that the state is only visually changed in the browser, not stored."),
'#default_value' => $settings['booked_state'],
'#options' => availability_calendar_get_states('label'),
'#required' => TRUE,
'#weight' => 13,
);
return $form;
}