node_type_form($form, &$form_state, $type = NULL)Generates the node type editing form.
modules/node/content_types.inc, line 69
<?php
function node_type_form($form, &$form_state, $type = NULL) {
if (!isset($type->type)) {
// This is a new type. Node module managed types are custom and unlocked.
$type = node_type_set_defaults(array('custom' => 1, 'locked' => 0));
}
// Make the type object available to implementations of hook_form_alter.
$form['#node_type'] = $type;
$form['name'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
'#default_value' => $type->name,
'#description' => t('The human-readable name of this content type. This text will be displayed as part of the list on the <em>Add new content</em> page. It is recommended that this name begin with a capital letter and contain only letters, numbers, and spaces. This name must be unique.'),
'#required' => TRUE,
'#size' => 30,
'#field_suffix' => ' <small id="edit-name-suffix">' . ($type->locked ? t('Machine name: @name', array('@name' => $type->type)) : ' ') . '</small>',
);
if (!$type->locked) {
$js_settings = array(
'type' => 'setting',
'data' => array(
'machineReadableValue' => array(
'name' => array(
'text' => t('Machine name'),
'target' => 'type',
'searchPattern' => '[^a-z0-9]+',
'replaceToken' => '_',
),
),
),
);
$form['type'] = array(
'#title' => t('Machine name'),
'#type' => 'textfield',
'#default_value' => $type->type,
'#maxlength' => 32,
'#required' => TRUE,
'#description' => t('The machine-readable name of this content type. This text will be used for constructing the URL of the <em>add new content</em> page for this content type. This name must contain only lowercase letters, numbers, and underscores. Underscores will be converted into hyphens when constructing the URL of the <em>add new content</em> page. This name must be unique.'),
'#attached' => array(
'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
),
);
}
else {
$form['type'] = array(
'#type' => 'value',
'#value' => $type->type,
);
}
$form['description'] = array(
'#title' => t('Description'),
'#type' => 'textarea',
'#default_value' => $type->description,
'#description' => t('Describe this content type. The text will be displayed on the <em>Add new content</em> page.'),
);
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
);
$form['submission'] = array(
'#type' => 'fieldset',
'#title' => t('Submission form settings'),
'#collapsible' => TRUE,
'#group' => 'additional_settings',
);
$form['submission']['title_label'] = array(
'#title' => t('Title field label'),
'#type' => 'textfield',
'#default_value' => $type->title_label,
'#required' => TRUE,
);
if (!$type->has_title) {
// Avoid overwriting a content type that intentionally does not have a
// title field.
$form['submission']['title_label']['#attributes'] = array('disabled' => 'disabled');
$form['submission']['title_label']['#description'] = t('This content type does not have a title field.');
$form['submission']['title_label']['#required'] = FALSE;
}
$form['submission']['body_label'] = array(
'#title' => t('Body field label'),
'#type' => 'textfield',
'#default_value' => isset($type->body_label) ? $type->body_label : '',
'#description' => t('To remove the body field, remove text and leave blank.'),
);
$form['submission']['node_preview'] = array(
'#type' => 'radios',
'#title' => t('Preview before submitting'),
'#default_value' => variable_get('node_preview_' . $type->type, DRUPAL_OPTIONAL),
'#options' => array(
DRUPAL_DISABLED => t('Disabled'),
DRUPAL_OPTIONAL => t('Optional'),
DRUPAL_REQUIRED => t('Required'),
),
);
$form['submission']['help'] = array(
'#type' => 'textarea',
'#title' => t('Explanation or submission guidelines'),
'#default_value' => $type->help,
'#description' => t('This text will be displayed at the top of the page when creating or editing content of this type.'),
);
$form['workflow'] = array(
'#type' => 'fieldset',
'#title' => t('Publishing options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
$form['workflow']['node_options'] = array('#type' => 'checkboxes',
'#title' => t('Default options'),
'#default_value' => variable_get('node_options_' . $type->type, array('status', 'promote')),
'#options' => array(
'status' => t('Published'),
'promote' => t('Promoted to front page'),
'sticky' => t('Sticky at top of lists'),
'revision' => t('Create new revision'),
),
'#description' => t('Users with the <em>Administer content</em> permission will be able to override these options.'),
);
$form['display'] = array(
'#type' => 'fieldset',
'#title' => t('Display settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
$form['display']['node_submitted'] = array(
'#type' => 'checkbox',
'#title' => t('Display author and date information.'),
'#default_value' => variable_get('node_submitted_' . $type->type, TRUE),
'#description' => t('Author username and publish date will be displayed.'),
);
$form['display']['teaser_length'] = array(
'#type' => 'select',
'#title' => t('Length of trimmed content'),
'#default_value' => variable_get('teaser_length_' . $type->type, 600),
'#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'),
'#description' => t("The maximum number of characters used in the trimmed version of content.")
);
$form['old_type'] = array(
'#type' => 'value',
'#value' => $type->type,
);
$form['orig_type'] = array(
'#type' => 'value',
'#value' => isset($type->orig_type) ? $type->orig_type : '',
);
$form['base'] = array(
'#type' => 'value',
'#value' => $type->base,
);
$form['custom'] = array(
'#type' => 'value',
'#value' => $type->custom,
);
$form['modified'] = array(
'#type' => 'value',
'#value' => $type->modified,
);
$form['locked'] = array(
'#type' => 'value',
'#value' => $type->locked,
);
$form['actions'] = array('#type' => 'container', '#attributes' => array('class' => array('form-actions')));
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save content type'),
'#weight' => 40,
);
if ($type->custom) {
if (!empty($type->type)) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete content type'),
'#weight' => 45,
);
}
}
return $form;
}
?>