function theme_webform_civicrm_options in Webform CiviCRM Integration 7.3
Same name and namespace in other branches
- 6.2 webform_civicrm_d6_functions.inc \theme_webform_civicrm_options()
- 7.2 webform_civicrm_d7_functions.inc \theme_webform_civicrm_options()
Drupal theme callback Format civicrm options form as a table
1 theme call to theme_webform_civicrm_options()
- _wf_crm_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_admin.inc, line 1317
Code
function theme_webform_civicrm_options($variables) {
$element = $variables['element'];
$element['civicrm_defaults']['']['#attributes']['class'][] = 'select-all-civi-defaults';
$default_box = drupal_render($element['civicrm_defaults']['']);
$select_box = '<input class="select-all-civi-options" type="checkbox" checked="checked" title="' . t('Select All') . '"> ';
$table = array(
'rows' => array(),
'attributes' => array(
'id' => 'civicrm-options-table',
),
'sticky' => FALSE,
);
if (empty($element['civicrm_options'])) {
$table['header'] = array(
t('Item'),
$default_box . t('Selected'),
);
}
else {
$table['header'] = array(
t('Item'),
t('Weight'),
array(
'data' => $select_box . t('Enabled'),
'class' => array(
'live-options-hide',
),
),
array(
'data' => t('Label'),
'class' => array(
'live-options-hide',
),
),
$default_box . t('Default'),
);
drupal_add_tabledrag('civicrm-options-table', 'order', 'self', 'civicrm-option-weight');
}
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'] = array(
'civicrm-option-weight',
);
$element['civicrm_options'][$k]['#attributes']['class'] = array(
'civicrm-enabled',
);
$element['civicrm_option_label_' . $v]['#attributes']['class'] = array(
'civicrm-label',
);
$row[] = drupal_render($element['civicrm_option_weight_' . $v]);
$row[] = array(
'data' => drupal_render($element['civicrm_options'][$k]),
'class' => array(
'live-options-hide',
),
);
$row[] = array(
'data' => drupal_render($element['civicrm_option_label_' . $v]),
'class' => array(
'live-options-hide',
),
);
}
$element['civicrm_defaults'][$k]['#attributes']['class'] = array(
'civicrm-default',
);
$row[] = drupal_render($element['civicrm_defaults'][$k]);
$table['rows'][] = array(
'data' => $row,
'class' => array(
'draggable',
),
);
}
}
return drupal_render_children($element) . theme('table', $table);
}