function _content_admin_field_add_new in Content Construction Kit (CCK) 6
Same name and namespace in other branches
- 5 content_admin.inc \_content_admin_field_add_new()
1 string reference to '_content_admin_field_add_new'
- _content_admin_field_add in includes/
content.admin.inc - Menu callback; presents the form for adding a new field.
File
- includes/
content.admin.inc, line 459 - Administrative interface for content type creation.
Code
function _content_admin_field_add_new(&$form_state, $type_name, $new_field_name = '') {
$field_types = _content_field_types();
$widget_types = _content_widget_types();
$form = array();
$field_type_options = array();
foreach ($field_types as $field_name => $field_type) {
foreach ($widget_types as $widget_name => $widget_type) {
if (in_array($field_name, $widget_type['field types'])) {
$field_type_options[$field_name . '-' . $widget_name] = $widget_type['label'];
}
}
}
if (count($field_type_options) > 0) {
$form['new'] = array(
'#type' => 'fieldset',
'#title' => t('Create new field'),
);
$form['new']['field']['field_name'] = array(
'#title' => t('Field name'),
'#type' => 'textfield',
'#default_value' => $new_field_name,
'#field_prefix' => 'field_',
'#description' => t("The machine-readable name of the field. This name cannot be changed later! The name will be prefixed with 'field_' and can include lowercase unaccented letters, numbers, and underscores. You'll be able to choose a human-readable label for the field on next page."),
'#required' => TRUE,
);
$form['new']['field_widget_type'] = array(
'#type' => 'radios',
'#title' => t('Field type'),
'#required' => TRUE,
'#options' => $field_type_options,
'#default_value' => NULL,
'#theme' => 'content_admin_field_add_new_field_widget_type',
);
$form['new']['submit'] = array(
'#type' => 'submit',
'#value' => t('Continue'),
);
$form['new']['type_name'] = array(
'#type' => 'value',
'#value' => $type_name,
);
}
else {
drupal_set_message(t('No field modules are enabled. You need to <a href="!modules_url">enable one</a>, such as text.module, before you can add new fields.', array(
'!modules_url' => url('admin/build/modules'),
)), 'error');
}
return $form;
}