The following node has a short overview of the thoughts behind this patch,
http://drupal.org/node/155253

The groups page:
http://groups.drupal.org/node/4891
links between this patch and the piece needed in the cck module which is required for this patch to work.

Basically, this patch adds an "editable" tag to fields, and then, if they are CCK widgets, uses the CCK module to display the form elements instead of the normal output.

The upshot is, you can have editable items within the view, which all get submitted at once...

I hope people find it helpful :-)

Comments

merlinofchaos’s picture

Status: Needs review » Needs work

Ok, you got a good idea here. But a few things are a little off.

For one, and this is fairly minor, it's not quite adhering to code style.

For two, and this one is killer, you're hardcoding this to CCK, which is something Views tries to avoid. What needs to happen here is that it needs to be turned into more generic handlers that CCK can respond to (so it needs a second patch to CCK to implement that portion, unless CCK's handlers already return adequate information in which they can be used directly). That would make it so that any module can put up form elements.

For three, how well does this integrate with http://drupal.org/node/103171 ? That effort has been going on for some time, and I am thinking that a useful patch is going to come out of that at some point here. I was hoping they'd have more progress by now, but I've been lax in encouraging them to continue the work. So I want to make sure that one or the other effort does not get completely derailed. I'm going to put a pointer on that issue to check out this issue so that we can get efforts put together.

markfoodyburton’s picture

For one, and this is fairly minor, it's not quite adhering to code style.

Let me know whats wrong, I'll fix it - I read through the coding style guidelines and nothing jumped out...

For two, and this one is killer, you're hardcoding this to CCK, which is something Views tries to avoid. What needs to happen here is that it needs to be turned into more generic handlers that CCK can respond to (so it needs a second patch to CCK to implement that portion, unless CCK's handlers already return adequate information in which they can be used directly). That would make it so that any module can put up form elements.

I agree, - yes, ideally one module would have nothing to do with another. There is actually a part of the code that could be changed to add in the ability to make use of other modules - it's hard coded to only work with CCK right now, and core "node" items, or any others are dropped with a warning.... I'd say we should start with this, and aim to extend it as soon as we find other "node types" that would be useful? If CCK is to be adopted in the core, then I guess the question is not relevant anyway?

For three, how well does this integrate with http://drupal.org/node/103171 ? That effort has been going on for some time, and I am thinking that a useful patch is going to come out of that at some point here. I was hoping they'd have more progress by now, but I've been lax in encouraging them to continue the work. So I want to make sure that one or the other effort does not get completely derailed. I'm going to put a pointer on that issue to check out this issue so that we can get efforts put together.

So, the only person who got back to me about this when I originally posted was Mark. And, as I commented on the page, thats where I started looking. However, as best as I can tell, his patch is orthogonal to this one. There is also "editviews" which is also aimed at some of the same sort of functionality. But I think the use case, and the eventual functionality you need is different.

In my case, I am looking for something that I suspect will be relatively common, a view of some CCK enabled nodes, in which I can provide my user the ability to update, probably only one field....
Examples:

  • A "shopping basket" where you can adjust the number of items (but not their description of unit price)
  • A "todo" list, where you can update how far through you are in the task (but you would use the full node edit to change the text)

As far as I can tell, none of the other modules and patches are aimed at these use cases.

markfoodyburton’s picture

StatusFileSize
new10.29 KB

I am REALLY sorry, I made a mistake in the previous patch, and the important patch to the views_ui didn't get included!

In terms of trying to factor this code OUT of the views module itself, I had a look at this.

There is a "core" requirement that the underlying database, and database access functions have the "editable" field in them, but this is a very small patch.
The views_ui.module could be "branched" to be a views_ui_editable.module, though I see very little point in doing this?
I suspect it would be possible to move some of the collection of rendering information down into a "theme", but this would seem to me to place a very heavy burden on a theme, with little gain, other than to make the theme dependent on both views and cck, rather than to say that editable functionality depends upon CCK (though CCK is optional for views itself). I believe CCK is optional for views itself, as things stand, in that if CCK exists, then the views module is capable of doing things (like displaying CCK fields) that it would not do otherwise. It seems to me that the editable functionality is nothing more than an extension of that optional requirement.

I would love to hear other peoples views on this matter, and more, if people disagree, or have other ways of achieving the same goals, I'd love for them to edit the code....

karens’s picture

I would take this in a slightly different direction. You are adding an 'editable' value to the field which will always display the field as a form if you have edit rights, when in fact you might have some views where you want to edit it and others where you want to view it. I would enable this as a formatter instead, so when you create the view you can choose whether to display the field value or an edit form, in the same way you choose a display format for any CCK field. Adding that kind of formatter can be done (I think, not tested) with no changes to CCK core or Views as a new module that creates formatters for various fields and provides some code to display them as form elements.

Something else interesting to investigate is a jQuery in-place editor (http://jquery.com/plugins/project/jeditable). If you had that working you would create a formatter that displays the field value, but if you click on the field it becomes a form that can be edited, and the field value is updated in the background using jQuery.

There still might be changes needed to CCK core to make this work completely, but I'd at least try to see if it could be done as a new module.

If you got this working for CCK fields as formatters, you could then swing back around and try to figure out a way to do the same thing for non-CCK fields, which would need a different solution.

karens’s picture

Another interesting idea is to incorporate this into Views Calc where you could make any field in a table potentially editable -- could be very cool and I'd be very interested in adding something like that into Views Calc if you're willing to do some of the work.

markfoodyburton’s picture

Thanks for the feedback!

Actually, I am remiss in not telling people what I am currently up to.

First, I discovered a problem in the way I was treating the fields, so I have been re-working bits of the code.
Second, I wanted to include a "new" form - like editview has.

So, right now, I have gone the route of creating a new module, and - hey presto - I have done exactly what you have suggested and made it so that it's a formatter.

The issue is: Ideally, if somebody comes up with a "format as a long line around the edge of a screen" formatter - you should still be able to say "And I want that field to be editable". - So, my opinion is that this is a second rate solution. In the case you mention - where sometimes you want a view with, and sometimes without an editable field, whether you do this with a formatter or without, you still need two views. In one view you select some fields editable - in the other you dont.

My idea is that I will patch JUST the cck module to make it so that all CCK widgets present an editable "option" to the view module - this way, I wont even have to patch the view module. - I'm not there yet, and I dont know if this will work - however, again, it is a second rate option. While my view is that there is no place for non-cck objects in the world, and I'd like rid of title and body, none the less, they exist, and they should be editable via this means - however - since I dont care about those, I wasn't going to put the work into making them editable anyway, so this solution works for me....

On the jquery stuff and views calc -
Yes and Yes.
My plan was to get it working - still not there - I have some issue with setting values in the "new" form (I want the filters of the view to be used as the values in the "new" form, and it's not working for me yet, but I'll get there I'm sure :-))
Then, next - clean up the code
Then, next - make it jqueryable - for speed and elegance
At that point making it a spreadsheet with vcalc sounds like a real cool plan :-)

markfoodyburton’s picture

I have created a new module that does 99% of the work of this patch, So, the patch is no longer needed, thanks to merlinofchaos to pointing me towards the plan. It has a feature I dont like, namely that the "edit-ability" of a field should not depend upon the view type, but in order to process the options, it seems that having an editable table/list is about the only choice. Maybe with views 2 this might change? Anyway, it hangs together OK, so PLEASE try this module out ( http://project/editablefields ). It still relies on a CCK patch, which I dont like, but as yet, I dont see a good way round.

As for integrating with viewcalc, it's on the to-do list :-) - as is making the thing more AJAX'y, to speed things up for the user.

At present, the module displays a form at the bottom, and tries to guess at defaults based on the views filters/arguments, I hope it works :-)

sun’s picture

Version: 5.x-1.x-dev » 6.x-2.x-dev

Bumping this to 6.x, as 5.x is major feature-freezed. However, I don't know whether a different concept is planned for 6.x.

markfoodyburton’s picture

As the #7 says, there was not a need for the patch to views in 5, the 'editablefields' module did the job on it's own.

HOWEVER, a lot of people seem to be using editable fields, ( and I have to say, I am in the process of putting together the simplest of web sites, and, for even this very very simple case, I seem to need something like editablefields :-( )

So - I would __LOVE__ to see editablefields support natively (AND PROPERLY) in Views/CCK. The editablefields module, I consider to be a plaster, not a great solution :-(

Any hint's tips, ideas well received, and I'm happy to help a little if I can.

Cheers

Mark.

merlinofchaos’s picture

I do have plans to include decent support for this in Views 3, which will be the next major release after Views 2 final. I would very happily work with the editable fields module developer in order to service the needs. I have a design that I had worked out but I'm not 100% sure if it's the right design, and that design assumed a more strict fapi than I have to work with now.

That said, sun is right; Drupal 5 views is feature frozen, that is, unless a dedicated Views 1 maintainer wants to continue to work with it, and even then features should only be added to it on a very limited basis.

But I haven't the time to maintain it particularly, so right now all that's happening is that sun is applying some bug fixes here and there in prep for 1.7's release.

markfoodyburton’s picture

Sounds like we're all in agreement, I'll work with merlinofchaos off line, if there is anything I can do... But for View's 1 and Drupal 5, this is essentially closed.

Cheers

Mark.

karens’s picture

BTW, one of the new features in D6 CCK was written with this kind of thing in mind -- for CCK fields you can call content_field_form($form, $form_state, $field, $get_delta) (the function is in content.node.form.inc) and pass in the $field and the specific $delta value of that field you want, and it will return a properly configured edit form for that field. I'm sure there will be hiccups to work out, but this should, in theory, work. I'm doing something similar while developing #119102: Combo field - group different fields into one and you'll need to use some of the same tricks I'm using there.

rolf van de krol’s picture

Status: Needs work » Closed (won't fix)

This issue has been inactive for quite a while and therefore closed.

Please reopen if you disagree or want to work on this.

--triage-ddd-nl