Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Field UI's alteration of the node type form causes problems for other modules that want to alter the same form:
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;
}
}
- if your module's hook_form_alter() runs before this one, then you can add a submit handler in $form['actions']['submit'] as expected
- if your module's hook_form_alter() runs after this one, then attempting to do that will have no effect. You need to add it to $form['actions']['save_continue'] (and strictly speaking, check whether Field UI module is present!)
Comments
Comment #2
yogeshmpawarComment #3
catchThis could be done in a minor release.