function theme_webform_civicrm_options in Webform CiviCRM Integration 6.2
Same name and namespace in other branches
- 7.2 webform_civicrm_d7_functions.inc \theme_webform_civicrm_options()
- 7.3 webform_civicrm_admin.inc \theme_webform_civicrm_options()
Theme function to format civicrm options form as a table
1 theme call to theme_webform_civicrm_options()
- _webform_civicrm_webform_component_form_alter in ./
webform_civicrm_admin.inc - Alter back-end webform component edit forms. Called by hook_form_alter() whenever editing a webform component.
File
- ./
webform_civicrm_d6_functions.inc, line 126 - Keep all functions specific to a version of Drupal here, to allow the rest of the code to be version-independent.
Code
function theme_webform_civicrm_options($element) {
if ($element['civicrm_defaults']['#type'] == 'checkboxes') {
$default_box = '<input class="select-all-civi-defaults" type="checkbox" ' . (empty($element['civicrm_defaults']['#default_value']) ? '' : 'checked="checked"') . 'title="' . t('Select All') . '"> ';
}
else {
$default_box = drupal_render($element['civicrm_defaults']['']);
}
$select_box = '<input class="select-all-civi-options" type="checkbox" checked="checked" title="' . t('Select All') . '"> ';
if (empty($element['civicrm_options'])) {
$header = array(
t('Item'),
$default_box . t('Selected'),
);
}
else {
$header = array(
t('Item'),
t('Weight'),
$select_box . t('Enabled'),
t('Label'),
$default_box . t('Default'),
);
drupal_add_tabledrag('civicrm-options-table', 'order', 'self', 'civicrm-option-weight');
}
$table = array();
foreach (element_children($element['civicrm_defaults']) as $k) {
if ($k) {
$v = str_replace('_web_civi_option_selected_', '', $k);
$row = array(
drupal_render($element['civicrm_option_name_' . $v]),
);
if (!empty($element['civicrm_options'])) {
$element['civicrm_option_weight_' . $v]['#attributes']['class'] = 'civicrm-option-weight';
$element['civicrm_options'][$k]['#attributes']['class'] = 'civicrm-enabled';
$element['civicrm_option_label_' . $v]['#attributes']['class'] = 'civicrm-label';
$row[] = drupal_render($element['civicrm_option_weight_' . $v]);
$row[] = drupal_render($element['civicrm_options'][$k]);
$row[] = drupal_render($element['civicrm_option_label_' . $v]);
}
$element['civicrm_defaults'][$k]['#attributes']['class'] = 'civicrm-default';
$row[] = drupal_render($element['civicrm_defaults'][$k]);
$table[] = array(
'data' => $row,
'class' => 'draggable',
);
}
}
drupal_render($element);
$output = theme_table($header, $table, array(
'id' => 'civicrm-options-table',
));
// Disable drupal sticky headers because they cause invalid markup
return str_replace('<thead>', '<thead class="tableHeader-processed">', $output);
}