From 490fd34fb046163ab46084c3663e23606dfe46d1 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sun, 22 Nov 2009 03:13:01 +0000 Subject: #617632 by zserno, rszrama, and sign: Add a Save & Add Fields button when adding a content type. --- modules/field_ui/field_ui.module | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'modules') diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module index 5d11c6ee3..6d75f281b 100644 --- a/modules/field_ui/field_ui.module +++ b/modules/field_ui/field_ui.module @@ -305,3 +305,28 @@ function field_ui_inactive_instances($obj_type, $bundle_name = NULL) { } return $inactive; } + +/** + * Add a button Save and add fields to Create content type form. + */ +function field_ui_form_node_type_form_alter(&$form, $form_state) { + // We want to display the button only on add page. + if (empty($form['#node_type']->type)) { + $form['save_continue'] = array( + '#type' => 'submit', + '#value' => t('Save and add fields'), + '#weight' => 45, + ); + $form['#submit'][] = 'field_ui_form_node_type_form_submit'; + } +} + +/** + * Redirect to manage fields form. + */ +function field_ui_form_node_type_form_submit($form, &$form_state) { + if ($form_state['clicked_button']['#parents'][0] === 'save_continue') { + $form_state['redirect'] = 'admin/structure/types/manage/'. $form_state['values']['type'] .'/fields'; + } +} + -- cgit v1.2.3