You are here

function availability_calendar_booking_formlet_field_settings_form_inc in Availability Calendars 7.5

Implements hook_field_settings_form(). @link http://api.drupal.org/api/drupal/modules--field_ui--field_ui.api.php/fun...

1 call to availability_calendar_booking_formlet_field_settings_form_inc()
availability_calendar_booking_formlet_field_settings_form in booking_formlet/availability_calendar_booking_formlet.module
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.inc, line 93
General helper methods for Availability Calendar Booking formlet to make the .module file smaller:

Code

function availability_calendar_booking_formlet_field_settings_form_inc($field) {
  module_load_include('inc', '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,
  );
  $language_list = function_exists('locale_language_list') ? locale_language_list() : array();
  if (count($language_list) > 1) {
    $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 URLs typically point to a webform.") . ' ' . t("Do not start internal URLs 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(
      // Use invisible as this field must also be visible when the checkbox does not exist.
      'invisible' => array(
        ':input[name="field[settings][define_per_language]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  if (count($language_list) > 1) {
    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,
          // Use visible as these fields may only be visible when the the checkbox does exist.
          '#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,
  );
  $form['use_get'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use GET (instead of POST)'),
    '#description' => t('Webform 7.x-4.x does not support %post tokens anymore, so check this option if the URL above is pointing to a webform and you have installed a 7.x-4.x version.'),
    '#default_value' => $settings['use_get'],
    '#required' => FALSE,
    '#weight' => 14,
  );
  return $form;
}