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.
Following up on #2443499: User profile: Unable to chage image field style formatter options because they don't get saved
When you are editing the value of a field via FAPE, it won't actually change the preview.
Steps to reproduce:
- Create a new 'Content page' with some text in the body
- Click "Customize this page" and the settings on the body widget
- Make some changes to the body text
- Wait a bit and notice the preview doesn't update
- Click "Continue" and go to the field formatter settings - the preview still doesn't update
See screenshot:
Comment | File | Size | Author |
---|---|---|---|
#12 | panopoly_test-fape-preview-2454947-12.patch | 2.71 KB | cboyden |
#10 | panopoly_magic-fape-preview-2454947-10.patch | 3.46 KB | cboyden |
#9 | panopoly_magic-fape-preview-2454947-9.patch | 4.27 KB | dsnopek |
Screenshot 2015-03-18 13.01.30.png | 32.29 KB | hanoii |
Comments
Comment #1
hanoiiNow I do not know if this is an issue, strangely enough, I am nto seeing this any more, maybe it was the first patch, I am
notnow using the latest patch on the referenced issue and that doesn't seem to have the issue.Comment #2
dsnopekInteresting! When I was working on that other issue, I was able to reproduce your problem. For me, it was showing the preview when first opening the settings dialog, but not updating it when I made any changes. I suspect it would just show "[no preview]" when first adding it. I haven't had a chance to re-test, though!
Comment #3
hanoiisomething is not quite right. I upgraded to 1.19, now I am struggling a lot with a simple content type in which I have configured to be panelized. However, when editing the content type panelizer for teaser, I get this [no preview] from time to time. Can't reproduce it consistently though!
One thing I am missing to understand if it's related is that the teaser panel had all of the fields there, but nothing was displayed. Only until I went to the field, configure it and save I started to see the field content in the teaser.
Comment #4
hanoiiHmm, I know see that [no preview] on content type is fine as there's nothing to preview, live preview with selecting a node id doesn't seem to work, but that's probably another issue altogether.
Comment #5
dsnopekI think I've narrowed down the issue as I was seeing it (hopefully the same as you). Basically, when are editing the value of a field via FAPE, it won't actually change the preview. Which is why I was always seeing "[no preview]" when first creating a widget and filling in it's value.
Comment #6
cboyden CreditAttribution: cboyden at UC Berkeley Web Platform Services commentedThis is still an issue. I'm seeing it when customizing a page to change the image style of the Featured Image field.
Comment #7
dsnopekThe problem here seems to be that we aren't updating the settings of the field in a way that the CTools plugin can see those changes when rendering.
Here's a patch that fixes updating the preview when editing the field value, so for example, editing the body field through FAPE. This is what's described in the issue summary here.
However, there's a couple problems:
Comment #8
dsnopekThis patch is a little closer. There's a hack to allow images to render - I tried a bunch of things using the Field API, but couldn't get anything working, which is why I went for the hack which basically special cases on images/files. It still doesn't update the preview based on field formatter settings changes, but it gets a little closer: previously the preview wasn't even actually reloading after changes, and now it is - but strangely the configuration changes don't end up in
$form_state['values']
and I'm not sure why.So, this still needs some more work! And once that's done, this will need piles and piles of testing. :-)
Comment #9
dsnopekHere's a new patch!
It's a little less hacky, in that it remove the special casing for file/image fields, and instead calls the fields
hook_field_load()
, which fixes it in the case of file/image fields (and will hopefully allow this to work generally).And it's got the field formatter settings actually affecting the preview! However, that feels a little hacky (although not super badly) because it's directly looking at
$form_state['input']
rather than$form_state['values']
.This will a TON of testing to make sure it doesn't break something somewhere.
Ideally, this would also have some new tests, because we don't want to break this again.
Comment #10
cboyden CreditAttribution: cboyden at UC Berkeley Web Platform Services commentedThe third chunk of this patch almost-duplicates something from #3030479: Notice: Undefined index: triggering_element in panopoly_magic_form_ctools_entity_field_content_type_formatter_options_alter(). Would it be possible to commit that issue and remove the third chunk here? Updated patch without it is attached.
Comment #11
dsnopekSure, I merged the other issue
Comment #12
cboyden CreditAttribution: cboyden at UC Berkeley Web Platform Services commentedHere's a patch for panopoly_test that adds steps for FAPE live preview (body field text and image field style) to the existing FAPE test.
Comment #13
cboyden CreditAttribution: cboyden at UC Berkeley Web Platform Services commentedThe Magic patch is working as expected. I'm able to see changes in Live Preview when editing text in a Body field, and when changing the image style of an image field. For the new tests, they fail without the Magic patch, and pass with it.
Comment #14
dsnopekThanks! Here's a Travis build:
https://travis-ci.org/panopoly/panopoly/builds/580391695
Comment #15
dsnopekThe changes in this patch have been making me a little nervous, but after some thought, I think they're gonna be OK. Looking at the 3 hunks in the patch:
Hunks 1 and 2: These are hacks, specifically for dealing with field formatters settings, which I think are weird because it's using a CTools Wizard to make the field formatter settings on a 2nd page. It would be nice to not have to special case for just this particular instance, but this is an important widget, and looking at the code, I think the chance of regression is small.
Hunk 3: This is a totally sensible thing to do (aka not a hack) and it makes a lot of sense, but calling the Field API directly is always kinda weird and easy to get wrong. Hopefully there aren't any fields out there in contrib that won't work with this, but I guess we'll find out. :-) While not a hack, I see this as having a higher chance of a regression.
Anyway, I think the risk here is acceptable, so I'll merge once Travis gets back.
Comment #16
dsnopekTravis failed because Travis. :-( Here's a new build that should work better:
https://travis-ci.org/panopoly/panopoly/builds/580422954
Comment #18
dsnopekTests pass! Committed :-)