function field_ui_form_node_type_form_alter

field_ui_form_node_type_form_alter(&$form, FormStateInterface $form_state)

Implements hook_form_FORM_ID_alter().

Adds a button 'Save and manage fields' to the 'Create content type' form.

See also

node_type_form()

field_ui_form_node_type_form_submit()

File

core/modules/field_ui/field_ui.module, line 125
Allows administrators to attach custom fields to fieldable types.

Code

function field_ui_form_node_type_form_alter(&$form, FormStateInterface $form_state) {
  // We want to display the button only on add page.
  if ($form_state->getFormObject()->getEntity()->isNew()) {
    $form['actions']['save_continue'] = $form['actions']['submit'];
    $form['actions']['save_continue']['#value'] = t('Save and manage fields');
    $form['actions']['save_continue']['#weight'] = $form['actions']['save_continue']['#weight'] + 5;
    $form['actions']['save_continue']['#submit'][] = 'field_ui_form_node_type_form_submit';
    // Hide the 'Save content type' button.
    $form['actions']['submit']['#access'] = FALSE;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!field_ui!field_ui.module/function/field_ui_form_node_type_form_alter/8.1.x