We're using the edit module with Panels and Views and it works almost perfectly in all cases. The only issue occurs when the edited field is rewritten back to the page you end up with two field labels in some cases.
For example, when outputting entity fields in a Panel layout, if you select any other method than "Above" for the field label in the pane settings you end up with double field labels after editing.
Another example of odd behavior with rendering the labels after editing would be when using Views tables to render fields. When using the field template on Views fields, the editor can be initialized on them, however once again when you finish editing, the label is now present along with the updated value. Makes the table cells look a little weird to say the least.
Unless there's a specific technical reason for rendering the labels again, I'd suggest just writing out the field value instead. It would make the inline editing that much more versatile out of the box. You can't assume the field label is always rendered to the page nor the manner in which it is rendered.
I'd be glad to help just need to be pointed in the right direction to get started.
Comments
Comment #1
minorOffense CreditAttribution: minorOffense commentedSorry, just re-read my original issue title and the sentence structure was terrible. Here's attempt number two.
Comment #2
nod_It's probably because the view mode is missing. Can you paste the content of the ajax call to
/edit/metadata
for your page?( edit ) very little was done for views/panels at the moment, this will be worked on in the coming weeks.
Comment #3
nod_Comment #4
minorOffense CreditAttribution: minorOffense commentedSure thing. There are two instances of "field_givenname" on this page. One with the label above, one with no label. I've also included a snapshot from the pane configuration pages. In both instances, after editing the label is added.
Looking at the json, I can see that
_custom_display
at the end of each field. Is that where the view mode should be?{"icms_debtor\/3\/field_givenname\/und\/_custom_display":{"label":"First Name","access":true,"editor":"form","aria":"Entity icms_debtor 3, field First Name"},"icms_debtor\/3\/field_middle_names\/und\/_custom_display":{"label":"Middle Name(s)","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Middle Name(s)"},"icms_debtor\/3\/field_surname\/und\/_custom_display":{"label":"Last Name","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Last Name"},"icms_debtor\/3\/field_alias\/und\/_custom_display":{"label":"Alias","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Alias"},"icms_debtor\/3\/field_previous_bankruptcy\/und\/_custom_display":{"label":"Previous Bankruptcy","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Previous Bankruptcy"},"icms_debtor\/3\/field_debtor_province_filed\/und\/_custom_display":{"label":"Province filed","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Province filed"},"icms_debtor\/3\/field_date_of_birth\/und\/_custom_display":{"label":"Date of Birth","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Date of Birth"},"icms_debtor\/3\/field_sin\/und\/_custom_display":{"label":"Social Insurance Number","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Social Insurance Number"},"icms_debtor\/3\/field_debtor_gender\/und\/_custom_display":{"label":"Gender","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Gender"},"icms_debtor\/3\/field_debtor_language\/und\/_custom_display":{"label":"Language","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Language"},"icms_debtor\/3\/field_debtor_education\/und\/_custom_display":{"label":"Education","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Education"},"icms_debtor\/3\/field_debtor_dependents\/und\/_custom_display":{"label":"Dependents","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Dependents"},"icms_debtor\/3\/field_debtor_marital_status\/und\/_custom_display":{"label":"Marital Status","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Marital Status"},"icms_debtor\/3\/field_marital_status_since\/und\/_custom_display":{"label":"Marital Status Since","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Marital Status Since"},"icms_debtor\/3\/field_debtor_occupation\/und\/_custom_display":{"label":"Occupation","access":true,"editor":"form","aria":"Entity icms_debtor 3, field Occupation"}}
Comment #5
nod_Thanks.
Yes, the
_custom_display
should be the proper view mode of the field.I'm not working on the panels support yet, I'll be looking at that early next week.
Comment #6
minorOffense CreditAttribution: minorOffense commentedOk cool. Well let me know if there's anything else I can do.
As a side note, should we consider changing the _custom_display to only render the value? I assume that's a kind of fallback for when the view mode isn't available. I guess you could make an argument for both including or excluding the label as the default and/or fallback behaviour.
Comment #7
nod_Looked at it, we're going to need a panels wizard for the rescue. It's either very tricky or I missed a major piece of panels API that makes it simpler.
Comment #8
nod_I have 4 days left on D7 edit module on it. With the other issues it's hardly possible for me to fix it for me in this time.
Comment #9
Wim LeersTrying to improve the title, because this problem definitely does not happen "out of the box".
Can you please confirm that this change accurately reflects the problem at hand?
Comment #10
minorOffense CreditAttribution: minorOffense commentedYeah pretty much. I've had issues with the title myself ;-)
In short, if you output an editable field using Panels (using the field pane) or in Views (using the "Use field template" in the field settings) it makes the field editable but you get mixed results with the label after editing.
Comment #11
Wim LeersAlright — thanks. Those specifics are very helpful :)
Comment #12
Wim LeersThe Views half of this problem has been addressed in #1830518-25: Views integration (use Views' render pipeline to re-render edited fields in Views).
So let's make this issue solely about Panels.
Comment #13
Wim LeersThe Drupal 8 backport (#2111667: Backport Drupal 8's Edit module to Drupal 7) has made this issue fixable! It brings explicit support for custom render pipelines by defining a custom view mode and implementing
hook_edit_render_field()
. Seeedit.api.php
.Comment #14
Wim LeersNo matter what I do, I can't get a Panel node to use a custom display mode (which results in that
_custom_display
part at the end).Until I get very clear and precise steps to reproduce, I'm afraid I can't solve this. I don't have enough experience with Panels to be able to get Panels node working properly, it seems to me.
Comment #15
Wim LeersMarking as a postponed feature request as per #2168725: [META] Add support for in-place editing entity types other than Node:
Comment #16
Wim LeersComment #17
drupalninja99 CreditAttribution: drupalninja99 commented@minorOffense are you saying there is a way to use edit module with Panels when it overrides a view mode? I know that edit module will work for nodes embedded in a panel but I can't get it to work at all if Panels overrides the view mode.
Comment #18
DamienMcKennaMarked two other issues as duplicates:
Comment #19
minorOffense CreditAttribution: minorOffense commented@drupalninja99 We were able to get that working a long time ago. I haven't tried recently.
Comment #20
DamienMcKenna@minorOffense: Any pointers on how you got it to work?
Comment #21
drupalninja99 CreditAttribution: drupalninja99 commentedI wonder if it was patched to remove integration with Panels after they discovered problems.
Comment #22
Wim LeersI've got it working, in these four scenarios:
I tested both the node title and the field_tags field in those four scenarios. The field_tags field was always overridden with a custom title in Panelizer, with the first field item hidden and the field items displayed in reverse order (to make sure that we definitely are using Panelizer's render pipeline). Always tested with an article node.
To get this to work, I've had to write some of the ugliest work-arounds I've ever seen. And I've seen quite a few, having written https://drupal.org/project/hierarchical_select. Many kittens were tortured in the process: Panels/Page Manager/Panelizer do a lot of things very, very wrong.
The first two scenarios (i.e. those using the "page manager" panelizer view mode) required awful hacks (see the "part 1" patch). But what's worse is that additional hacks are needed for the last two scenarios (see the "part 2" patch). There's only a fairly small shared set of required hacks.
Hence I put as much as I could in
includes/panelizer.inc
, so that the hackiness is as contained as possible. I'm especially nervous about it since it's nigh impossible to provide test coverage for this.I'm posting this as a patch first instead of committing it right away, so that you can test it and provide feedback to make sure it's actually working before I tag a 1.1 release.
P.S.: make sure to clear all caches after applying this patch!
Comment #23
DamienMcKenna@Wm: Excellent work! Out of interest, for the problems you saw in CTools, Panels and Panelizer, how much of them are bugs / oddities that could be improved in those modules, thus lightening the load on Edit?
Comment #24
Wim Leers#23: the work-arounds fall in two categories:
panelizer_panelizer_pre_render_alter()
in the patch)panelizer_ctools_render_alter()
in the patch)Since I've never been successful in getting fixes committed to Panels, I didn't even consider filing patches. Should I reconsider that? :)
Comment #25
DamienMcKennaAs it happens, I know one of the Panelizer co-maintainers ;-)
Comment #26
saltednutPanels is co-maintained by Jakub Perry from Acquia and Panelizer is co-maintained by Damien here so we should be good with patches for both going forward.
Comment #27
saltednutI was trying to get the patch from #23 working but not having any success at first. I tried two workflows:
1. Install Drupal (using Lightning profile) with Edit 1.x-dev and Panelizer 3.x-dev
2. Appy patch
3. Clear all caches
or
1. Install Drupal (using Lightning profile) with Edit 1.x-dev (patch already applied) and Panelizer 3.x-dev
Both scenarios result in this JS error on Panelizer pages:
Uncaught TypeError: Cannot read property 'getAttribute' of undefined
I was worried maybe this was profile specific so I went ahead and subverted using the Lightning profile and went with vanilla Drupal 7.28 + Panelizer 3.x-dev (and dependencies Ctools and Panels both in dev) + Edit 1.x-dev with the patch applied and its dependencies (Entity 1.x-dev and Libraries 2.2). In this scenario... it seems to work. So now trying to figure out whats up with Lightning, but I think this is safe to RTBC if @DamienMcKenna approves.
Comment #28
saltednutI did some more testing with this and right now I can only get it to work using the Standard renderer. When I switch over to IPE, I get the
Uncaught TypeError: Cannot read property 'getAttribute' of undefined
.Demo: http://lightningfreedev.devcloud.acquia-sites.com
I have this mocked up to try out on this site. You can login with the user 'demo' and password 'demo' - the role is set up to allow creating and editing content. Basic Pages do not have Panelizer. Articles have Panelizer with Standard renderer. Landing Pages have Panelizer with IPE (error shown there).
Comment #29
Wim LeersI've now locally reproduced the problems described in #28. I can reproduce all problems with the "Landing Page" content type. For some reason, the
data-edit-entity-id
attribute does not get set for Landing Pages, which cases that JS error. But even if that weren't the case, it should break, because for some reason the view mode gets set topanelizer-
instead ofpanelizer-<panelizer view mode ID>
. Currently investigating.Note that on your demo site, Panelizer is not enabled for Article nodes, unlike what you're saying. I don't have permission to enable it there, but please enable it to verify that it is indeed working in that case.
Comment #30
Wim LeersVery happy to report that not only did I manage to fix it, but fixing this actually required me to remove a bunch of hacky code :) The situation is now a bit better!
(In short: I confused testing IPE + page_manager with IPE + teaser, and hence came to wrong conclusions and more complicated than necessary and because of that incomplete work-around.)
Now the patch is relatively sane:
panelizer_ctools_render_alter()
to adddata-edit-entity-id
edit_preprocess_panelizer_view_mode()
contextual-links-region
element being set on the wrong element (inedit_ctools_render_alter()
)(Also moved some things around to make it easier to follow along.)
Comment #31
saltednutJust tested #30 locally and its working well in all the scenarios I've tested. Have not had time yet to update the environment but I think this looks good from my tests.
Re: the demo environment.
Panelizer is enabled on the Article content type (its being overridden) but since the IPE is not turned on for that bundle, the 'Customize' and 'Layout' buttons are not enabled. You should be able to see the 'Panelizer' local task though if you are logged in and edit the panels stuff from the back-end.
Comment #32
Wim LeersSo, let's try to make this patch simpler by fixing the other modules.
For hack #2, I opened #2267601: Impossible to get (or even calculate) the Panelizer view mode in theme layer.
For hack #1, I tried opening an issue with a suggested fix, but to fix it, we either need to introduce a new hook in the
if (module_exists('contextual') …) {…}
part ofctools_context_handler_render_handler()
, which is a no-go, or we must fix the CTools API and therefore break it. The key problem is this:This causes
contextual-links-region
to be set on a newly created container of the actual contextual region, instead of on the actual contextual region. The reason it works this way is because$info['content']
is allowed to be a string. That should not be allowed; it should always be a render array. (This is where an API change would be necessary.)Because a string may be returned as the main page content instead of a render array, it's impossible to just set a class on the top-level element render array. Hence the way CTools works around this is by necessity. But Edit needs to be able to set an additional
data-
attribute on the same element as the element that has thecontextual-links-region
class. But to do so, we would need to add an additional hook — it is assumed that no altering is ever necessary here; which would be true, ifcontextual-links-region
were actually set on the right element, but that's impossible, because it may have to operate on a string of markup instead of a renderable array.Conclusion: removing this hack is going to be more effort than it's worth.
Comment #33
saltednutI think this is ready to go.
Comment #34
DamienMcKenna@Wim: Can you please submit a patch in #2267601: Impossible to get (or even calculate) the Panelizer view mode in theme layer for whats needed there, I'll give it a review. Thanks.
Comment #35
Wim Leers#34: it's in the issue summary; can't you just indicate whether that's an acceptable solution?
Comment #36
DamienMcKennaUpdated to work with the patch in #2267601: Impossible to get (or even calculate) the Panelizer view mode in theme layer.
Comment #37
saltednutInterdiff?
Comment #38
DamienMcKennaI tested this out. The edit infrastructure does indeed load on a Panelized page, with fields being available for editing via a contextual menu. However, I don't see any way of saving the changes - there's no "save" button visible either globally, or in Admin Menu or Navbar. Am I missing something?
Comment #39
DamienMcKennaAn intediff for the patch in #36, as requested.
Comment #40
saltednutRe #38 - the 'Save' button appears only after making a change to a field. Screenshots below.
Before making an edit
After making an edit
Comment #41
DamienMcKennaDid either of you try it with ckeditor?
Comment #42
saltednutI have, yes.
Comment #43
DamienMcKenna@Brant: Try nesting the WYSIWYG field in a field group.
Comment #44
DamienMcKennaOk, it seems that #2190213: Add support for Field group was causing my testbed to not work correctly.
Comment #45
saltednutAh - I thought you might be trolling me for a minute there. :)
Comment #46
DamienMcKennaExcluding the Field Group support, this appears to be working. Excellent sleuthing, Wim!
Comment #47
DamienMcKennaFYI I committed the patch in #2267601: Impossible to get (or even calculate) the Panelizer view mode in theme layer.
Comment #48
saltednutOne minor bug I found. Rendering a File Entity via Views provoked the error, but this could happen to any non-panelized entity I suppose.
The Panelizer view mode is not always set for every entity type, so we should ensure it exists before we start doing stuff with it.
Comment #49
Wim Leers#48: Perfect, thank you!
Comment #50
Wim LeersComment #51
Wim LeersAnd… committed! At last! :)
Attached is the patch that I committed — it has the necessary renaming since #2276941: [meta] Rename edit module to quickedit happened.
Brant: please do a final round of testing to confirm it's all working, then I'll tag a 1.1 release :)
Comment #53
Håvard CreditAttribution: Håvard commentedAfter switching to the 'Quick Edit'-module on latest Spark d7 php 5.3 the attached error message appeared. Any ideas?