function timefield_field_instance_settings_form in Timefield 7
Implements hook_field_instance_settings_form().
File
- ./
timefield.module, line 137 - Defines a Field API field for time
Code
function timefield_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
$library = timefield_library();
$has_library = !empty($library);
if (!$has_library) {
drupal_set_message("You will not have enhanced time input widget without downloading the plugin. " . l("Read installation instructions here.", 'http://drupalcode.org/project/timefield.git/blob_plain/HEAD:/README.txt', array(
'absolute' => TRUE,
)), 'warning');
}
$form['disable_plugin'] = array(
'#title' => t('Disable jQuery Timepicker plugin.'),
'#type' => 'checkbox',
'#default_value' => isset($settings['disable_plugin']) ? $settings['disable_plugin'] : empty($library) ? TRUE : FALSE,
'#description' => t('Do not use jQuery Timepicker plugin for input.'),
'#disabled' => empty($library),
);
$form['input_format'] = array(
'#title' => t('Time Input Format'),
'#type' => 'fieldset',
);
$form['input_format']['separator'] = array(
'#title' => t('Hour and Minute Separator'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['separator']) ? $settings['input_format']['separator'] : ':',
'#size' => 10,
'#description' => t('The character to use to separate hours and minutes.'),
);
$form['input_format']['showLeadingZero'] = array(
'#title' => t('Show Leading Zero for Hour'),
'#type' => 'checkbox',
'#default_value' => isset($settings['input_format']['showLeadingZero']) ? $settings['input_format']['showLeadingZero'] : FALSE,
'#description' => t('Whether or not to show a leading zero for hours < 10.'),
);
$form['input_format']['showPeriod'] = array(
'#title' => t('Show AM/PM Label'),
'#type' => 'checkbox',
'#default_value' => isset($settings['input_format']['showPeriod']) ? $settings['input_format']['showPeriod'] : FALSE,
'#description' => t('Whether or not to show AM/PM on the input textfield both on the widget and in the text field after selecting the time with the widget.'),
);
$form['input_format']['periodSeparator'] = array(
'#title' => t('What character should appear between the time and the Period (AM/PM)'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['periodSeparator']) ? $settings['input_format']['periodSeparator'] : '',
'#size' => 10,
'#description' => t('The character to use to separate the time from the time period (AM/PM).'),
);
$form['input_format']['am_text'] = array(
'#title' => t('AM text'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['am_text']) ? $settings['input_format']['am_text'] : 'AM',
'#size' => 10,
);
$form['input_format']['pm_text'] = array(
'#title' => t('PM text'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['pm_text']) ? $settings['input_format']['pm_text'] : 'PM',
'#size' => 10,
);
$form['input_format']['showCloseButton'] = array(
'#title' => t('Show a Button to Close the Picker Widget'),
'#type' => 'checkbox',
'#default_value' => isset($settings['input_format']['showCloseButton']) ? $settings['input_format']['showCloseButton'] : FALSE,
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['closeButtonText'] = array(
'#title' => t('Close Button text'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['closeButtonText']) ? $settings['input_format']['closeButtonText'] : 'Close',
'#size' => 10,
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['showNowButton'] = array(
'#title' => t('Show a Button to Select the Current Time'),
'#type' => 'checkbox',
'#default_value' => isset($settings['input_format']['showNowButton']) ? $settings['input_format']['showNowButton'] : FALSE,
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['nowButtonText'] = array(
'#title' => t('Now Button text'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['nowButtonText']) ? $settings['input_format']['nowButtonText'] : 'Now',
'#size' => 10,
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['showDeselectButton'] = array(
'#title' => t('Show a Button to Deselect the time in the Picker Widget'),
'#type' => 'checkbox',
'#default_value' => isset($settings['input_format']['showDeselectButton']) ? $settings['input_format']['showDeselectButton'] : FALSE,
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['deselectButtonText'] = array(
'#title' => t('Deselect Button text'),
'#type' => 'textfield',
'#default_value' => isset($settings['input_format']['deselectButtonText']) ? $settings['input_format']['deselectButtonText'] : 'Deselect',
'#size' => 10,
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['myPosition'] = array(
'#title' => t('my Position'),
'#type' => 'select',
'#default_value' => isset($settings['input_format']['myPosition']) ? $settings['input_format']['myPosition'] : 'left top',
'#options' => drupal_map_assoc(array(
'left top',
'left center',
'left bottom',
'center top',
'center center',
'center bottom',
'right top',
'right center',
'right bottom',
)),
'#description' => t('Corner of the timpicker widget dialog to position. See !jquery_info for more info.', array(
'!jquery_info' => l(t("jQuery UI Position documentation"), 'http://jqueryui.com/demos/position', array(
'absolute' => TRUE,
)),
)),
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['input_format']['atPosition'] = array(
'#title' => t('at Position'),
'#type' => 'select',
'#options' => drupal_map_assoc(array(
'left top',
'left center',
'left bottom',
'center top',
'center center',
'center bottom',
'right top',
'right center',
'right bottom',
)),
'#default_value' => isset($settings['input_format']['atPosition']) ? $settings['input_format']['atPosition'] : 'left bottom',
'#description' => t('Where to position "my Position" relative to input widget textfield See !jquery_info for more info.', array(
'!jquery_info' => l(t("jQuery UI Position documentation"), 'http://jqueryui.com/demos/position', array(
'absolute' => TRUE,
)),
)),
'#states' => array(
'invisible' => array(
':input[name="instance[settings][disable_plugin]"]' => array(
'checked' => TRUE,
),
),
),
);
return $form;
}