function _webform_edit_time in Webform 5.2
Same name and namespace in other branches
- 5 components/time.inc \_webform_edit_time()
- 6.3 components/time.inc \_webform_edit_time()
- 6.2 components/time.inc \_webform_edit_time()
- 7.4 components/time.inc \_webform_edit_time()
- 7.3 components/time.inc \_webform_edit_time()
Create a set of form items to be displayed on the form for editing this component. Use care naming the form items, as this correlates directly to the database schema. The component "Name" and "Description" fields are added to every component type and are not necessary to specify here (although they may be overridden if desired).
Return value
An array of form items to be displayed on the edit component page
File
- components/
time.inc, line 36 - Webform module time component.
Code
function _webform_edit_time($currfield) {
$edit_fields = array();
$edit_fields['value'] = array(
'#type' => 'textfield',
'#title' => t('Default value'),
'#default_value' => $currfield['value'],
'#description' => t('The default value of the field.') . '<br />' . t('Accepts a time in any <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>. Strings such as now, +2 hours, and 10:30pm are all valid.'),
'#size' => 60,
'#maxlength' => 127,
'#weight' => 0,
'#validate' => array(
'webform_validate_time_string' => array(),
),
);
$edit_fields['extra']['timezone'] = array(
'#type' => 'radios',
'#title' => t('Timezone'),
'#default_value' => empty($currfield['extra']['timezone']) ? 'site' : $currfield['extra']['timezone'],
'#description' => t('Adjust the time according to a specific timezone. Website timezone is defined in the <a href="!settings">Site Settings</a> and is the default.', array(
'!settings' => url('admin/settings/date-time'),
)),
'#options' => array(
'site' => 'Website Timezone',
'user' => 'User Timezone',
'gmt' => 'GMT',
),
'#weight' => 0,
);
$edit_fields['extra']['check_daylight_savings'] = array(
'#type' => 'checkbox',
'#title' => t('Observe Daylight Savings'),
'#default_value' => $currfield['extra']['check_daylight_savings'],
'#checked_value' => 1,
'#description' => t('Automatically adjust the time during daylight savings.'),
'#weight' => 1,
);
$edit_fields['extra']['hourformat'] = array(
'#type' => 'radios',
'#title' => t('Time Format'),
'#default_value' => isset($currfield['extra']['hourformat']) ? $currfield['extra']['hourformat'] : '12-hour',
'#description' => t('Format the display of the time in 12 or 24 hours.'),
'#options' => array(
'12-hour' => '12-hour (am/pm)',
'24-hour' => '24-hour',
),
'#weight' => 2,
);
return $edit_fields;
}