function FieldUiHooks::formAlter
Implements hook_form_alter().
Adds a button 'Save and manage fields' to forms.
See also
\Drupal\comment\CommentTypeForm
\Drupal\block_content\BlockContentTypeForm
field_ui_form_manage_field_form_submit()
File
-
core/
modules/ field_ui/ src/ Hook/ FieldUiHooks.php, line 254
Class
- FieldUiHooks
- Hook implementations for field_ui.
Namespace
Drupal\field_ui\HookCode
public function formAlter(&$form, FormStateInterface $form_state, $form_id) : void {
$forms = [
'node_type_add_form',
'comment_type_add_form',
'media_type_add_form',
'block_content_type_add_form',
];
if (!in_array($form_id, $forms)) {
return;
}
if ($form_state->getFormObject()
->getEntity()
->isNew()) {
$form['actions']['save_continue'] = $form['actions']['submit'];
unset($form['actions']['submit']['#button_type']);
$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_manage_field_form_submit';
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.