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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

minorOffense’s picture

Title: Render edited fields rewrite only the edited value instead of both label and value » Render field value only after editing instead of both label and value

Sorry, just re-read my original issue title and the sentence structure was terrible. Here's attempt number two.

nod_’s picture

Category: feature » task

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.

nod_’s picture

Assigned: Unassigned » nod_
minorOffense’s picture

Sure 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"}}

nod_’s picture

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.

minorOffense’s picture

Ok 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.

nod_’s picture

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.

nod_’s picture

Assigned: nod_ » Unassigned
Status: Active » Postponed

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.

Wim Leers’s picture

Title: Render field value only after editing instead of both label and value » Render field value only after editing instead of both label and value when using custom view modes of Panels & Views

Trying 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?

minorOffense’s picture

Yeah 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.

Wim Leers’s picture

Alright — thanks. Those specifics are very helpful :)

Wim Leers’s picture

Title: Render field value only after editing instead of both label and value when using custom view modes of Panels & Views » Panels integration (use Panels' render pipeline to re-render edited field panes in Panels)

The 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.

Wim Leers’s picture

Issue summary: View changes
Status: Postponed » Active

The 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(). See edit.api.php.

Wim Leers’s picture

Title: Panels integration (use Panels' render pipeline to re-render edited field panes in Panels) » Panels node support (use Panels' render pipeline to re-render edited field panes in Panels?)
Status: Active » Postponed (maintainer needs more info)

No 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.

Wim Leers’s picture

Category: Task » Feature request
Status: Postponed (maintainer needs more info) » Postponed

Marking as a postponed feature request as per #2168725: [META] Add support for in-place editing entity types other than Node:

To get a 1.0 stable release of Edit out the door, a scope has been determined:

  • support for in-place editing nodes
  • support for using Edit in combination with Panels pages to do page layouts

Otherwise, Edit would probably be in a perpetual beta, in order to test against all entity types in Drupal 7. Drupal 7's Entity API was a contrib afterthought, not part of Drupal core, hence there are lots of subtle problems — Edit has helped consolidate Entity API in Drupal 8.

Thank you for your understanding.

Wim Leers’s picture

drupalninja99’s picture

@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.

DamienMcKenna’s picture

minorOffense’s picture

@drupalninja99 We were able to get that working a long time ago. I haven't tried recently.

DamienMcKenna’s picture

@minorOffense: Any pointers on how you got it to work?

drupalninja99’s picture

I wonder if it was patched to remove integration with Panels after they discovered problems.

Wim Leers’s picture

Title: Panels node support (use Panels' render pipeline to re-render edited field panes in Panels?) » Panelizer support (use Panels' render pipeline to re-render edited field panes in Panels)
Version: 7.x-1.x-dev » 7.x-1.0
Status: Postponed » Needs review
Issue tags: +Spark
FileSize
10.52 KB
7.25 KB
5.95 KB

I've got it working, in these four scenarios:

  1. panelizer view mode = page_manager, renderer = standard
  2. panelizer view mode = page_manager, renderer = IPE
  3. panelizer view mode = teaser et al, renderer = standard
  4. panelizer view mode = teaser et al, renderer = IPE

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!

DamienMcKenna’s picture

@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?

Wim Leers’s picture

#23: the work-arounds fall in two categories:

  1. small things that are being done incorrectly, but could be fixed fairly easily ("oddities", best example: panelizer_panelizer_pre_render_alter() in the patch)
  2. more fundamental flaws, that either require rearchitecting or big BC breaks ("bugs", best example: 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? :)

DamienMcKenna’s picture

As it happens, I know one of the Panelizer co-maintainers ;-)

saltednut’s picture

Panels 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.

saltednut’s picture

I 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.

saltednut’s picture

Status: Needs review » Needs work

I 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).

Wim Leers’s picture

I'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 to panelizer- instead of panelizer-<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.

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
9.5 KB
6.04 KB

Very 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:

  • for page_manager ("full page") nodes, we have panelizer_ctools_render_alter() to add data-edit-entity-id
  • for panelizer view mode ("actual view mode") nodes, we have edit_preprocess_panelizer_view_mode()
  • hack #1 is to fix the contextual-links-region element being set on the wrong element (in edit_ctools_render_alter())
  • hack #2 is to pass the panelizer view mode along with the entity being rendered, because that's information that's otherwise impossible to get at

(Also moved some things around to make it easier to follow along.)

saltednut’s picture

Just 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.

Wim Leers’s picture

So, 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 of ctools_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:

      $build = array(
        '#theme_wrappers' => array('container'),
        '#attributes' => array('class' => array('contextual-links-region')),
      );

      if (!is_array($info['content'])) {
        $build['content']['#markup'] = $info['content'];
      }
      else {
        $build['content'] = $info['content'];
      }

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 the contextual-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, if contextual-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.

saltednut’s picture

Status: Needs review » Reviewed & tested by the community

I think this is ready to go.

DamienMcKenna’s picture

@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.

Wim Leers’s picture

#34: it's in the issue summary; can't you just indicate whether that's an acceptable solution?

DamienMcKenna’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Status: Reviewed & tested by the community » Needs review
FileSize
8.82 KB
saltednut’s picture

Interdiff?

DamienMcKenna’s picture

I 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?

DamienMcKenna’s picture

An intediff for the patch in #36, as requested.

saltednut’s picture

FileSize
724.43 KB
586.76 KB

Re #38 - the 'Save' button appears only after making a change to a field. Screenshots below.

Before making an edit

After making an edit

DamienMcKenna’s picture

Did either of you try it with ckeditor?

saltednut’s picture

FileSize
245.17 KB

I have, yes.

DamienMcKenna’s picture

@Brant: Try nesting the WYSIWYG field in a field group.

DamienMcKenna’s picture

Ok, it seems that #2190213: Add support for Field group was causing my testbed to not work correctly.

saltednut’s picture

Ah - I thought you might be trolling me for a minute there. :)

DamienMcKenna’s picture

Status: Needs review » Reviewed & tested by the community

Excluding the Field Group support, this appears to be working. Excellent sleuthing, Wim!

DamienMcKenna’s picture

saltednut’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +demo_framework
FileSize
608 bytes
8.93 KB

One 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.

Wim Leers’s picture

#48: Perfect, thank you!

Wim Leers’s picture

Project: Edit » Quick Edit
Wim Leers’s picture

Version: 7.x-1.x-dev »
Status: Needs review » Fixed
FileSize
9.34 KB

And… 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 :)

  • Commit 22e5029 on 7.x-1.x by Wim Leers:
    Issue #1889798 by Wim Leers, DamienMcKenna, brantwynn | minorOffense:...
Håvard’s picture

Version: » 7.x-1.x-dev
FileSize
69.49 KB

After switching to the 'Quick Edit'-module on latest Spark d7 php 5.3 the attached error message appeared. Any ideas?

Status: Fixed » Closed (fixed)

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