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.
I have simple CCK 'Member' with integer 'Age' field, and I check revision option on so each modification for Member node, will have revisions. I use views and make 'Age' field editable (AJAX).
I found out that when I modify one of row from views, no revision is made.
I made a small line to file: editablefields.module line 318, adding line $node->revision = 1;
, here's the snippet code..
if ($node->{$field_name}[$delta] != $form_state['values'][$field_name][0]) {
$node->{$field_name}[$delta] = $form_state['values'][$field_name][0];
$node->revision = 1; //there should be a mechanism to check whether this node-type uses revision.
node_save($node);
}
Now. the revision is made correctly when I modify from views.
Comment | File | Size | Author |
---|---|---|---|
#7 | editablefields-1189196-7.patch | 637 bytes | mwsam |
Comments
Comment #1
vulzan CreditAttribution: vulzan commentedI too had the same issue and was going crazy trying to figure this out. I added the code you list above. Rebooted my server (just cuz that's how I roll), changed the editability in my view to not editable and saved. Changed it back again to editable using AJAX and saved. Cleared Drupal caches (Drupal cache and views cache) and my my browser cache, and still, no new version is saved when changing the field value in views. It creates a new version on the node/edit form, of course, but not in views. I am using Drupal 6.20, editablefields version 6.x-2.0, revisioning version 6.x-3.11, and views 6.x-2.12. Any ideas besides upgrading everything? I have a ton of modules installed ... and I mean a ton.
Comment #2
tannerjfco CreditAttribution: tannerjfco commentedJust noticed this is also an issue with the 7.x version. Fields edited using editable fields do not track a revision when "create new revision" is set on the node, though normal editing from the node will track the revision.
Comment #3
nooysters CreditAttribution: nooysters commentedYes having this issue with the 7 version. Is there a quick fix like the 6 version? ex. $node->revision = 1; Looking at the module file but cannot see where a similar fix would go.
Comment #4
invisibleink CreditAttribution: invisibleink commentedThis seems to be a result of the Entity API not supporting revisions. Since editable_fields uses Entity API for loading and saving, it seems that the field system is not getting the revision property from the node.
While the nice folks over at Entity API are working on Support revisions in Entity API, maybe someone with a better understanding of this module could figure out a way to use a different load and save for entities that are actually nodes?
I tried using the 7x-1.x-dev of Entity module, and applying the patch from #20 of the above issue, but saw no affect....either on the behavior of editable_fields revision saving, or on the properties that were getting loaded.
Apologies if I've totally misunderstood the problem...just following a trail, and hoping for help making this work!
Comment #5
dtarc CreditAttribution: dtarc commentedIt seems that hook_node_save() never gets called when editing fields via views (and maybe other places, we are only using it in views).
It seems very odd, Because I would've thought entity_save() would call node_save().
We discovered the issue because we wanted to trigger changes in other fields when a change was made to the editable field and we couldn't do it in node_save() strangely.
Comment #6
presleyd CreditAttribution: presleyd commentedI issued a bounty for these issues:
#1405854: Multiple fields not saved
#1206656: Error on Node view page: Argument 1 passed to drupal_array_get_nested_value()
#1189196: Doesn't create revision on content-type which revision option is checked.
and I think #1449750: Title field does not save changes (I'm not 100% sure if I understood the problem here but took it to just be problems saving from Views displays which I need but didn't test if it worked previously)
Mwsam has produced fixes, once I finish my tests tomorrow (so I can pay him) he'll post patches here.
Comment #7
mwsam CreditAttribution: mwsam commentedHere is a patch against the latest 7.x-1.x branch. This the fork I used when I'm working on multiple issues of editablefields: https://github.com/mwsam/editablefields
Comment #8
drjonez CreditAttribution: drjonez commentedThe above patch appears to work fine, though it seems that it slows down the "saving" of content. That's a minor consequence. It might be nice to have an option in the view field to turn on or off saving of revisions, but this gets us to where we need to be.
At any rate, thanks for this, it really helps!
Comment #9
NWOM CreditAttribution: NWOM commentedThanks a lot for the patch. It still works perfectly!
Comment #10
dags CreditAttribution: dags commentedFixed in 7.x-1.x-dev. Thanks for the patch @mwsam!
As a consequence of this patch, if a user is making several field-level revisions on an editable form, then we end up with a bunch of small revisions as opposed to one big revision like we'd get when using a regular node/edit form. Not really an issue, just something to think about...