Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
node system
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
14 Aug 2015 at 02:08 UTC
Updated:
21 Sep 2015 at 11:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
larowlanData loss during preview is major in my books
NodeForm/preview is node module so I reckon stick it there for now?
Comment #3
kattekrab commentedComment #4
kattekrab commentedGah. sorry. save conflicts.
back to node system and major and adding related issue
#2548713: Only one additional new value saved unlimited field and no non-field values are restored after preview
Comment #5
kattekrab commentedComment #6
jibranData loss means critical
Comment #7
kattekrab commentedJibran - well the data hasn't actually been saved yet - so it's debateable whether that's critical.
This has always been the problem with preview. Nothing is saved until the user hits save.
Comment #8
legolasboIt's not just the alt field, the title field is also emptied when enabled. However, i cannot reproduce the loss of images. These are my steps to reproduce on current head (commit 8ba635b)
1. Edit article content type and make image field unlimited.
2. Add images and alt text to node, click Preview.
3. Go back, alt text is missing.
4. Add alt text again, click preview.
5. Go back, all is fine.
Comment #9
legolasboTrying to debug this.
Comment #10
legolasboIssue also occurs on fields with a limited cardinality.
Attached patch fixes the issue.
Comment #11
hazaI confirm that the issue is still present.
I've tested the patch, and it fixes the issue (even if I can't really understand why this simple foreach fixes the issue).
We should be able to add a test for this I think, then we should be able to RTBC.
Comment #12
legolasbo@Haza,
I agree tests should be added.
Hopefully the explanation below helps you understand.
variable $form_state holds a reference to the form state object. In the code above it gets assigned the value of $preview, which causes the reference to the actual form_state object to be lost. This in turn causes any changes to $form_state to no longer propagate to the form state object that was originally passed in.
By setting the values of $preview one by one, we are actually updating the form state object in stead of overwriting it's reference.
Comment #13
hazaHo, I see now. Thanks for the explanations !
Comment #14
larowlanWorking on a test
Comment #15
larowlanfail/pass
Comment #16
legolasboComment #18
jibranCode changes looks good just needs a manual testing and some minor feedback.
A Comment here would help a lot.
Comment #19
lauriiiAdded beta-evaluation
Comment #20
kattekrab commented/me testing.
Comment #21
kattekrab commentedManually tested - alt and title text not lost with the patch. Reconfirmed they are lost against head.
Nicely done!
Comment #22
hazaWhile testing the patch, I found an other "issue" that is also fixed by the patch.
The issue
- Fresh D8 install
- Add Content > Article
- Fill the title, do not add an image, clic "preview"
- In the preview window, go back to the node edit page.
- Try to add an image, it silently fails.
Am I not able to reproduce this with the attached patch (that's why I do not create an other core issue), but maybe we could also add a test for this case ?
What do you think (leaving this as RTBC) ?
Comment #23
legolasbo@Haza,
I think you should add a new issue for the issue you found and postpone it on this issue. We can then add the tests for it in that issue.
Comment #24
larowlanWe have #2548713: Only one additional new value saved unlimited field and no non-field values are restored after preview for that one, see you over there :)
Comment #25
hazaAwsome, thanks the link to the other issue.
Comment #26
catchCommitted/pushed to 8.0.x, thanks!