Problem

You can't add new content, if the entity requires an preview first. The save button don't show up.

Reproduce the bug:

  1. login as administrator
  2. open admin/structure/types/manage/page
  3. Submission form settings > Preview before submitting > set required and save
  4. create new content node/add/page
  5. the blue save button didn't appear, even after the preview

Expectation / Suggestion

The "Save and publish" button should show up, once the preview was seen.
Eventually a save button within the preview would solve the problem as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Component: entity system » node system
Vj’s picture

I have made some change and its working now for drupal 8.x.

Can someone please test and confirm its working properly

charlesjc’s picture

Status: Active » Needs review
Damien Tournoud’s picture

Title: Can't create entity, if preview is required » Can't create node, if preview is required
Berdir’s picture

Issue tags: -preview, -Add Content +Needs tests

I have no idea what the field_storage there exactly means?

I suspect we simply no longer need this condition, as preview now works differently? I'm actually not sure how this is exactly supposed to work now that preview is on a separate page. To keep this, we somehow need to set a flag when we preview the first time?

Will also need tests.

mimran’s picture

just apply the patch as #2 it works like a charm

swentel’s picture

Hmm yeah, we'll probably need to store a flag in form state and set this to true once the preview has ben seen. We can default it to TRUE and make that conditional way easier then I guess, that get field_storage check looks weird indeed.

rvolk’s picture

Shouldn't we have a flag "preview_required" which should be set to false once the preview has been seen?
A second thought should be, if the flag resets to true once the content is edited again after preview - to fulfill the original intention of the content-type administrator: "Only publish previewed content". As long the content differs from the preview state a publishing option should not be available.

Berdir’s picture

Issue tags: +Usability

This setting is from before the preview system was changed to be on a separate patch.

The DX now is IMHO pretty confusing now, as it works like this: Add => fill out => preview => edit => save. So you need to go back to edit to be able to save.

For this to make sense, it seems that we should have a Save button next to "Edit again", then this would be very easy to solve, we would simply never show save on the edit form, just on preview.

If that is not possible, I'm wondering if we should remove this feature from core instead?

yoroy’s picture

What berdir says makes sense: if I must preview before I can save, then let me save directly from the preview. I guess before dropping a core feature we must at least ensure that contrib could make it work again.

swentel’s picture

There is an issue to try implement the save functionality on the preview screen itself, see #1899360: Add save dropbutton next to 'Back to content editing' link in node preview. - which is open for discussion of course :)

swentel’s picture

Issue tags: -Needs tests
FileSize
838 bytes
2.21 KB

So I was confused as well with the check on ->get('field_storage'). So I think we should look for a different approach. Attached patch introduces a hasBeenPreviewed property which is set to TRUE after coming from preview. Has tests as well.

We can look for adding a save button in the other issue, because that is a little more tricky to get right.

The last submitted patch, 12: 2354469-12-test-only.patch, failed testing.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks this makes a lot of sense.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.0.x. Thanks!

  • webchick committed fd4c6da on 8.0.x
    Issue #2354469 by swentel, Vj, R. Volk: Can't create node, if preview is...

Status: Fixed » Closed (fixed)

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