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.
Problem
You can't add new content, if the entity requires an preview first. The save button don't show up.
Reproduce the bug:
- login as administrator
- open admin/structure/types/manage/page
- Submission form settings > Preview before submitting > set required and save
- create new content node/add/page
- 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.
Comment | File | Size | Author |
---|---|---|---|
#2 | save_button_after_preview-2354469-2-d8.patch | 808 bytes | Vj |
#12 | 2354469-12.patch | 2.21 KB | swentel |
#12 | 2354469-12-test-only.patch | 838 bytes | swentel |
Comments
Comment #1
BerdirComment #2
Vj CreditAttribution: Vj commentedI have made some change and its working now for drupal 8.x.
Can someone please test and confirm its working properly
Comment #3
charlesjc CreditAttribution: charlesjc commentedComment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedComment #5
BerdirI 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.
Comment #6
mimran CreditAttribution: mimran commentedjust apply the patch as #2 it works like a charm
Comment #7
swentel CreditAttribution: swentel commentedHmm 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.
Comment #8
rvolkShouldn'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.
Comment #9
BerdirThis 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?
Comment #10
yoroy CreditAttribution: yoroy commentedWhat 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.
Comment #11
swentel CreditAttribution: swentel commentedThere 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 :)
Comment #12
swentel CreditAttribution: swentel commentedSo 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.
Comment #14
jibranThanks this makes a lot of sense.
Comment #15
webchickCommitted and pushed to 8.0.x. Thanks!