function weight_view_weight_form in Weight 7
Same name and namespace in other branches
- 6 weight.module \weight_view_weight_form()
Display a view as a weight changing table.
1 string reference to 'weight_view_weight_form'
- theme_weight_view_weight in ./
weight.views.inc - Display a view as a weight changing table.
File
- ./
weight.views.inc, line 226 - Views2 support for Weight module.
Code
function weight_view_weight_form($form, &$form_state, $header, $rows, $fields, $class, $id, $title) {
// Make this form draggable
drupal_add_tabledrag($id, 'order', 'sibling', 'weight_dragger');
$form = array(
'#tree' => TRUE,
);
$form['#variables'] = array(
'header' => $header,
'class' => $class,
'fields' => $fields,
'id' => $id,
'title' => $title,
);
foreach ($rows as $count => $row) {
if (is_numeric($count)) {
foreach ($row as $field => $content) {
$nid = $row->nid_hidden;
if (drupal_substr($field, 0, 6) == 'weight') {
$form['rows'][$count][$field] = array(
'#default_value' => $content,
'#type' => 'weight',
'#delta' => variable_get('weight_range', 20),
);
}
elseif ($field != 'nid_hidden') {
$form['rows'][$count][$field] = array(
'#type' => 'value',
'#value' => $content,
);
}
else {
$form['rows'][$count][$field] = array(
'#type' => 'hidden',
'#value' => $content,
);
}
}
}
foreach ($form['rows'][$count] as $key => $frow) {
if (!array_key_exists($key, $header) && $key != 'nid_hidden') {
unset($form['rows'][$count][$key]);
}
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}