When adding/editing a new content type, the user cannot add new fields on the initial 'add' page or manage page

admin/structure/types/add

admin/structure/types/manage/[content type]

The only option is to 'Save content type' which directs them back to their list of content types.

To improve the flow, let's have a new button with the label 'Save & Add Fields' that will direct people to the field management page at
admin/structure/types/manage/[content type]/fields

(This is from #614396: Clarify UI text on page for adding new content types comment #3. Bojhan, anything to add?)

Comments

lisarex’s picture

Title: Need a Save & Add Fields button when adding/editing a content type » Need a Save & Add Fields button when adding a content type
Status: Active » Needs work
StatusFileSize
new42.03 KB

Should be on the Add page only. See attached mockup. :)

Bojhan’s picture

So I am wondering, if this is part of the editing, or the creating a new content type workflow. I am to argue that since we will have Manage fields on content type page, it should not be part of editing a content type.

lisarex’s picture

Bojhan thanks, I saw your response in IRC. I can't edit the original issue (or can I?) but I clarified it should be for Add page only in comment 1.

rszrama’s picture

StatusFileSize
new1.23 KB

Here ya go. I tried to follow other button text patterns and so used "and" instead of "&" and sentence capitalization.

Can anyone who sees this tell me if there's already an issue regarding the fact that you lose the breadcrumb when you go to edit a content type? You can't click straight back to the list of content types.

Also, is it a new thing to have return statements at the end of form submit handlers? They seem quite unnecessary...

rszrama’s picture

Component: field_ui.module » node system
Status: Needs work » Needs review

(Forgot to set to "needs review." Also, the patch is for an include in the node module folder, so I tweaked the component.)

rszrama’s picture

Component: node system » field_ui.module
Status: Needs review » Needs work

Bah, and I just realized why this was marked for the fields_ui.module. Should've dawned on me sooner that this wouldn't be so simple... for those following along at home, this button should only show if the Field UI module is enabled. Gonna have to work it into that module as a form alter instead of this painless patch. : P

webchick’s picture

Issue tags: +D7 UX freeze

I'd like to see this in before UX freeze. It'd definitely make the workflow here much smoother.

lisarex’s picture

Hi, I've done a quick demo to show how this should work.

http://www.vimeo.com/7604361

Cheers!

sign’s picture

Status: Needs work » Needs review
StatusFileSize
new1.12 KB

Here is a patch based on #4, moved to field_ui.module

theunraveler’s picture

I tested this patch and it seems to work just fine. The code looks good too.

lisarex’s picture

StatusFileSize
new10.47 KB

Looks great buuuuut.... if I return to the edit the content type, the Delete button looks odd in the middle.

I think there's a slight preference for this button to only appear on the initial Add page, not subsequent, so that would mean not messing around with reordering the buttons.

See attached.

webchick’s picture

Status: Needs review » Needs work

Yeah, I agree with that. Let's put it there only on add.

Also, that $form_state['build_info']['args'][0]->type thing looks weird. It looks like $form has a #node_type index that'll work for this?

zserno’s picture

StatusFileSize
new1.19 KB

Attached an updated version of #9.
Changes:
- Based on #12, changed $form_state['build_info']['args'][0]->type to $form['#node_type'].
- Added a new check in submit handler, because previous versions of patch redirected regardless which submit button was clicked.
- Updated comments (periods and capital letters).

zserno’s picture

Status: Needs work » Needs review
StatusFileSize
new1.19 KB

Forgot to mark as patch...sorry.

zserno’s picture

Oh, so testing bot is re-checking attached patches, so there's no need to re-attach it. :)
My bad...anyway, please review it.

damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Worked as described:

  • At initial content type creation, adds a button labelled "Save and add fields".
  • Upon clicking the button the user is taken to the fields manager page.
  • Editing an existing content type doesn't have the "Save and add fields" button.

Anyone else want to review it?

webchick’s picture

Status: Reviewed & tested by the community » Fixed

This looks great, and really speeds up the interaction users are going to want in about 8/10 of the cases.

I made one teensy tweak which was to change:

if ($form['#node_type']->type === "") {

to:

  if (empty($form['#node_type']->type)) {

The first is perfectly correct, but we use empty() more often than not for legibility.

Committed to HEAD!

zserno’s picture

@webchick Wohoo!
Thanks for enlightening me. This was my first commit to Drupal and it feels really great! :)

yched’s picture

Status: Fixed » Active

Sorry to jump in late.

+    $form_state['redirect'] = 'admin/structure/types/manage/'. $form_state['values']['type'] .'/fields';

This needs to be strtr('_', '-', $form_state['values']['type']);, or this will break if the node type name has a _.
Ya know, the 'underscore to dash' conversion for node types in URLs we all love ;-)

yched’s picture

Er, or even better:
$form_state['redirect'] =_field_ui_bundle_admin_path('node', $form_state['values']['type']) . '/fields';

zserno’s picture

Status: Active » Needs review
StatusFileSize
new800 bytes

Adjusted the patch according to #20.
Although I tried and it works with '_' too, but it's definitely more consequent.

webchick’s picture

Status: Needs review » Fixed

Ah, good catch, yched. Committed to HEAD.

zserno: CONGRATS on your first core patch! WOOT! :D

lisarex’s picture

Yay! So glad this one made it in :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

traviscarden’s picture