function views_ui_add_field in Views (for Drupal 7) 5
Add all the info for a single field into the form.
File
- ./
views_ui.module, line 1302
Code
function views_ui_add_field(&$form, $field, &$order, $key, $i) {
$fields = _views_get_fields();
$fieldname = $form['id']['#value'];
// combined table & fieldname
$fieldinfo = $fields[$fieldname];
// laziness + readability
$form['fullname'] = array(
'#type' => 'hidden',
'#default_value' => $field['id'],
);
$form['name'] = array(
'#type' => 'markup',
'#value' => $fieldinfo['name'],
);
$form['queryname'] = array(
'#type' => 'hidden',
'#default_value' => $field['queryname'],
);
$form['tablename'] = array(
'#type' => 'hidden',
'#default_value' => $field['tablename'],
);
$form['field'] = array(
'#type' => 'hidden',
'#default_value' => $field['field'],
);
$form['label'] = array(
'#type' => 'textfield',
'#default_value' => $field['label'],
'#size' => 15,
'#maxlength' => 255,
);
if (is_array($fieldinfo['handler'])) {
$form['handler'] = array(
'#type' => 'select',
'#default_value' => $field['handler'],
'#options' => $fieldinfo['handler'],
);
}
if (isset($fieldinfo['option'])) {
$form['options'] = views_ui_setup_widget($fieldinfo['option'], $field['options']);
}
if ($fieldinfo['sortable']) {
$form['sortable'] = array(
'#type' => 'select',
'#default_value' => $field['sortable'],
'#options' => array(
'0' => t('No'),
'1' => t('Yes'),
),
);
$form['defaultsort'] = array(
'#type' => 'select',
'#default_value' => $field['defaultsort'],
'#options' => array(
'0' => t('None'),
'ASC' => t('Ascending'),
'DESC' => t('Descending'),
),
);
}
if (isset($fieldinfo['help'])) {
$form['help'] = array(
'#type' => 'markup',
'#value' => '<div class="description">' . $fieldinfo['help'] . '</div>',
);
}
}