function theme_webform_validation_manage_overview_form in Webform Validation 7
Themable function to list and re-order the rules assigned to a webform.
File
- ./
webform_validation.admin.inc, line 40 - Manages validation rules administration UI.
Code
function theme_webform_validation_manage_overview_form($variables) {
$form = $variables['form'];
$header = array(
t('Rule name'),
t('Validator'),
t('Components'),
t('Weight'),
array(
'data' => t('Operations'),
'colspan' => 2,
),
);
$rows = array();
foreach (element_children($form) as $rule) {
$row = array();
foreach (element_children($form[$rule]) as $item) {
// Unset the titles of the form elements, since we are displaying them in
// a table with a header.
unset($form[$rule][$item]['#title']);
// Add a class to the weight field.
$form[$rule]['weight']['#attributes']['class'] = array(
'ruleid-weight',
);
$row[] = array(
'data' => drupal_render($form[$rule][$item]),
);
}
if (count($row) > 1) {
$rows[] = array(
'data' => $row,
'class' => array(
'draggable',
),
);
}
// Hide any fieldsets, since we are displaying the form in a table.
if (isset($form[$rule]['#type']) && $form[$rule]['#type'] === 'fieldset') {
hide($form[$rule]);
}
}
$drag = TRUE;
if (!$rows) {
$drag = FALSE;
$rows[][] = array(
'data' => t('No validation rules available.'),
'colspan' => 5,
);
}
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'webform-validation-overview-form',
),
));
$output .= drupal_render_children($form);
if ($drag) {
drupal_add_tabledrag('webform-validation-overview-form', 'order', 'sibling', 'ruleid-weight');
}
return $output;
}