function _content_admin_field_add_new in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6 includes/content.admin.inc \_content_admin_field_add_new()
2 string references to '_content_admin_field_add_new'
- content_copy_import_form_submit in ./
content_copy.module - Submit handler for import form. For each submitted field: 1) add new field to the database 2) execute the imported field macro to update the settings to the imported values
- _content_admin_field_add in ./
content_admin.inc - Menu callback; presents the form for adding a new field.
File
- ./
content_admin.inc, line 501 - Administrative interface for content type creation.
Code
function _content_admin_field_add_new($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']['widget']['label'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => '',
'#description' => t('The machine-readable name of the field.<br/>Allowed characters : unaccentuated a-z, numbers and _. All other characters will be discarded.<br/>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,
'#theme' => 'content_admin_field_add_new_field_widget_type',
);
$form['new']['submit'] = array(
'#type' => 'submit',
'#value' => t('Create field'),
);
$form['new']['type_name'] = array(
'#type' => 'value',
'#value' => $type_name,
);
$form['new']['field_name'] = array(
'#type' => 'value',
'#value' => $new_field_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;
}