function theme_content_admin_field_overview_form in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6 includes/content.admin.inc \theme_content_admin_field_overview_form()
Theme the field overview table by iterating through the form and rendering form elements in table cells
File
- ./
content_admin.inc, line 199 - Administrative interface for content type creation.
Code
function theme_content_admin_field_overview_form($form) {
if (!$form['#table']) {
return;
}
// The css for this form contains non-validating styles,
// so we use a separate file, included only on the relevant page.
drupal_add_css(drupal_get_path('module', 'content') . '/content_admin.css');
$disabled = unserialize($form['disabled']['#value']);
if (module_exists('fieldgroup')) {
$header = array(
t('Label'),
t('Name'),
t('Type'),
t('Weight'),
t('Group'),
array(
'data' => t('Operations'),
'colspan' => 2,
),
);
$colspan = 7;
}
else {
$header = array(
t('Label'),
t('Name'),
t('Type'),
t('Weight'),
array(
'data' => t('Operations'),
'colspan' => 2,
),
);
$colspan = 6;
}
$rows = array();
$i = 0;
// The table was created in the form
// iterate through it and render form elements when placeholders are encountered
// then run the rows array through theme_table().
foreach ($form['#table'] as $weight => $frow) {
foreach ($frow as $delta => $item) {
foreach ($item as $fname => $field) {
$row = array();
$class = 'content-field-overview-enabled';
if (in_array($fname, $disabled)) {
$class = 'content-field-overview-disabled';
}
foreach ($field as $col => $cell) {
// display cols other than the group 'fields' col
if ($col != 'fields') {
switch ($cell) {
case 'form-field-weights':
$row[] = drupal_render($form['field-weights'][$fname]);
break;
case 'form-group-weights':
$row[] = drupal_render($form['group-weights'][$fname]);
break;
case 'form-field-groups':
$row[] = drupal_render($form['field-groups'][$fname]);
break;
default:
$row[] = array(
'data' => $cell,
'class' => $class,
);
}
}
elseif (isset($form['#groups'])) {
// if this form contains groups info and this is a group 'fields' col, finish the previous row
// then theme the 'fields' col with a fieldset containing a table and the group fields
$grows = array();
if (!empty($cell)) {
foreach ($cell as $gweight => $grow) {
foreach ($grow as $gdelta => $gitem) {
foreach ($gitem as $gname => $gfield) {
$grow = array();
foreach ($gfield as $gcol => $gcell) {
switch ($gcell) {
case 'form-field-weights':
$grow[] = drupal_render($form['field-weights'][$gname]);
break;
case 'form-field-groups':
$grow[] = drupal_render($form['field-groups'][$gname]);
break;
default:
$grow[] = $gcell;
}
}
$grows[] = array(
'data' => $grow,
'class' => 'content-field-overview-enabled',
);
}
}
}
}
else {
$grows[] = array(
array(
'data' => t('No fields have been added to this group.'),
'colspan' => $colspan,
'class' => 'content-field-overview-empty',
),
);
}
// add the group row in its own table above the group fields table, then reset $row().
$fieldset = array(
'#title' => t('!label (!name)', array(
'!label' => $form['#group_labels'][$fname],
'!name' => $fname,
)),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#value' => theme('table', array(), array(
array(
'data' => $row,
'class' => 'content-field-overview-group',
),
)) . theme('table', $header, $grows),
);
$row = array();
$row[] = array(
'data' => theme('fieldset', $fieldset),
'colspan' => $colspan,
'class' => 'active',
);
$grows = array();
}
}
$rows[] = $row;
}
}
}
$output = theme('table', $header, $rows, array(
'class' => 'content-field-overview',
));
$output .= drupal_render($form);
return $output;
}