function _webform_edit_optionsmarkup in Webform Options Markup 7
Same name and namespace in other branches
- 7.2 components/webform_optionsmarkup.inc \_webform_edit_optionsmarkup()
Implements _webform_edit_component().
File
- components/
webform_optionsmarkup.inc, line 49 - Webform component that allows markup in checkbox and radio options.
Code
function _webform_edit_optionsmarkup($component) {
$format_id = variable_get('optionsmarkup_input_format', 'filtered_html');
if (empty($format_id)) {
$format_id = filter_fallback_format();
}
$format = filter_format_load($format_id);
if (!filter_access($format)) {
drupal_set_message(t('You do not have permission to edit this component.'), 'error');
$nid = arg(1);
drupal_goto("node/{$nid}");
return array();
}
$form = array();
$select_admin_js = drupal_get_path('module', 'webform') . '/js/select-admin.js';
$form['#attached']['js'][$select_admin_js] = array(
'preprocess' => FALSE,
);
$form['#attached']['js'][] = array(
'data' => array(
'webform' => array(
'selectOptionsUrl' => url('webform/ajax/options/' . $component['nid']),
),
),
'type' => 'setting',
);
$form['extra']['items'] = array(
'#type' => 'textarea',
'#title' => t('Options'),
'#default_value' => $component['extra']['items'],
'#description' => t('<strong>Key-value pairs MUST be specified as "safe_key|Some readable title|Some readable description (can contain html markup)"</strong>. Use of only alphanumeric characters and underscores is recommended in keys. One option per line. Option groups may be specified with <Group Name>. <> can be used to insert items at the root of the menu after specifying a group.') . theme('webform_token_help'),
'#cols' => 60,
'#rows' => 5,
'#weight' => 0,
'#required' => TRUE,
'#wysiwyg' => FALSE,
'#element_validate' => array(
'_webform_edit_validate_optionsmarkup',
),
);
$form['value'] = array(
'#type' => 'textfield',
'#title' => t('Default value'),
'#default_value' => $component['value'],
'#description' => t('The default value of the field identified by its key. For multiple selects use commas to separate multiple defaults.') . theme('webform_token_help'),
'#size' => 60,
'#maxlength' => 1024,
'#weight' => 0,
);
$form['extra']['multiple'] = array(
'#type' => 'checkbox',
'#title' => t('Multiple'),
'#default_value' => $component['extra']['multiple'],
'#description' => t('Check this option if the user should be allowed to choose multiple values.'),
'#weight' => 0,
);
$form['display']['optrand'] = array(
'#type' => 'checkbox',
'#title' => t('Randomize options'),
'#default_value' => $component['extra']['optrand'],
'#description' => t('Randomizes the order of the options when they are displayed in the form.'),
'#parents' => array(
'extra',
'optrand',
),
);
return $form;
}