This means:
- adding the "Add more button";
- adding a "Save" button;

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andreiashu’s picture

Title: Fully support multi-valued fields » Fully support multi-valued CCK fields
Status: Active » Needs work
FileSize
4.57 KB

Work in progress. For now it will render the multiple entries (if the field has multiple values) and the "Add more button".
Currently tested/working only with simple CCK fields like Text (with Widgets textfield and checkboxes).
Attached patch for reference.

On a related note: #1048748: Add functional tests the Selenium tests pass with this patch.

andreiashu’s picture

FileSize
5.68 KB

Added back support for nodereference. nodereference_autocomplete widget is still broken...

TimelessDomain’s picture

Tried out this patch, but am having some troubles. Using latest views 2x release. The editable fields are only appearing on the first row in the view & not any rows below. (using views tagger style). The "add another item" buttons are appearing, but when i click them -> the field disappears completely.

What format(s) should this work with? Click to Edit, Editable (HTML) or Editable (Ajax)?

Is there going to be a configuration page where Add More & Save buttons can be turned on & off OR will they just be part of new formats? Or part of existing formats by default?

note- i am using editable imagefields & filefields so this feature may not be compatible with those yet.
Thanks

babbage’s picture

I tested this and it worked well for my main node content, using fields formatted with Editable (HTML). However, on the node display I also had a block that showed other nodes that were related to the current node via a nodereference field. The fields on those nodes were also displayed as Editable (HTML) and this had been working fine until I applied the patch above. Once I did, I saw a behaviour similar to TimelessDomain—that is, the editable fields were appearing on the first row of that view only, and all rows below did not display those fields at all... they were left blank. If the fields were formatted instead with default formatting they then all displayed correctly.

All fields were plain text fields.

Using latest 6.x-3.x of editablefields.

babbage’s picture

This is the problem section:

+  if (isset($rendered_elements[$field_name])) {
+    return;
+  }

As a test for whether the task in hand is done, it works for most fields but not ones that are rendered in Views, it would seem.

babbage’s picture

The patch in #2 assumes that if a field name has been encountered before, that field has already been processed, and it thus exits. This is what is required with this patch for multi-value fields, as otherwise you will end up with as many copies of the fields as there are values in the field. However, for editable fields displayed in a view it results in only the first occurrence of any field being displayed, with the rest omitted.

The attached patch re-rolls #2, providing a hacky work-around to address the problems identified in #3-#5 for one specific use case. In this patch, a specified content type is also checked for, and the processing is only exited if both the field name has been encountered before, and if the field was attached to the content type my_node_type (which can obviously be changed to anything else). This temporarily solves the problem for my particular problem case, where the views that were not working were all displaying content that was not from this content type, while the only content type that had editable fields with multiple values was the named content type.

Clearly, a better solution would be to modify the code to detect whether the field was being displaying in a node or a view, and not exit when the field is displayed in a view. (That would be more generalized but might still not solve the problem for someone who displays a multi-value field in a view and makes it editable?) But I wasn't smart enough to figure out how to do that today. At least my (patched) site is now working.

gthing’s picture

I tried the most recent patch (#6) and it is displaying some odd behavior. I am not able to edit fields as a group as before and I have no options to add a new field. Also, when I click on a field to edit, all of the other fields are duplicated.

Here's a short screencast: http://screencast.com/t/gSgiCRVIHm76

Note: Those are node reference fields.

_paul_meta’s picture

Great to see this issue getting some attention. I'm working on a drupal based application with a lot of cck and views. The ideal for me is to have views with multiple nodes having certain fields rendered as editable fields. This can include file fields and content taxonomy fields.

Just advising I have tested the latest dev build and got some errors for multiple value fields of field type file field and content taxonomy field. I also couldn't see the save button in some cases. All other use cases seemed ok.

I'd love to see a solution for this as it will add a lot of value to this module and make for some pretty nifty workflow screens. I will do some testing on any subsequent patches or releases. Thanks for your efforts.

_paul_meta’s picture

I've done some more testing tonight with the latest dev version and thought a few of these use cases might be useful to you.

I'm using editablefields as a views formatter for various types of fields, and always using editable (html) mode.

Single value fields work every time regardless of which widget (checkbox, textfield, text area, filefield etc)

When attempting the following multiple value fields i had these results:
(All fields have unlimited as the number of possible values, so they require add more buttons to work properly)

Multiple value nodereference field (checkbox widget)
- This worked perfectly! Correct number of node options were output and i can check and uncheck as required. Saves correctly when defocused.

Multiple value text field (textfield widget or textarea widget)
- If values for the fields already exist, correct number of field widgets are displayed. Saving works ok. No 'add more' button appears. No 'save' button appears.
- If no values exist for this field, only one field widget is displayed. Saving works ok for the single field. No add more button appears. No save button appears.

Multiple value filefield ::
- If values for the fields already exist, correct number of field widgets are displayed. File upload works. No 'add more button' appears. No 'save' button appears.
- If no values exist for this field, only one field widget is displayed. ile upload works. No 'add more' button appears. No 'save' button appears.

Multiple value content taxonomy field (checkbox widget) ::
Correct options for the taxonomy terms are displayed
- If values for the fields already exist, correct values are checked.
- If no values exist for this field, field is correctly rendered with no values checked
For either case, checking or unchecking a value results in an error being displayed within the field .. "error : warning: Illegal offset type in /home/.../public_html/includes/form.inc on line 1212."

It would be really amazing to have these situations working where in a view, multiple values can be edited, added, removed easily. The workflow improvements this could offer views is considerable! I'd be willing to support the development of these features with additional testing and even sponsorship.

Thanks very much

Paul

_paul_meta’s picture

I've now tested the patch at #6 in some of my views and had the following results:

Multiple value nodereference field (checkbox widget)
- Works perfectly

Multiple value content taxonomy field (checkbox widget) ::
Correct options for the taxonomy terms are displayed
Changes made seem to work ok but no change to the node's field is actually done.
When deselecting an option checkbox, the following error is displayed: error : warning: Illegal offset type in /home/.../public_html/codebase/includes/form.inc on line 1212.

Multiple value text field (textfield widget or textarea widget)
works partially but some errors:
- drag handles only appear on first row of a view, other rows get dropdown menu of integers for the order
- moving drag handles doesn't display a save button to save the order
- a table head is included in the table for the multiple fields with this - seems a bit strange -

:

- add another item button seems buggy - works ok for pressing it on the second row of a view adds an extra field input to the top row. if the top row had 2 or more blank extra rows added, this resets it back to 1.
- if i input say 4 values to the a field it works ok, but if i then refresh the view, i get 4 full field widgets displayed, each displaying the 4 inputs with their values and a blank input and the add more button.

Multiple value filefield ::
works partially but some errors:
- drag handles only appear on first row of a view, other rows get dropdown menu of integers for the order
- moving drag handles doesn't display a save button to save the order
- occassionally i get this error after an upload - although the upload does seem to succeed. warning: array_merge() [function.array-merge]: Argument #1 is not an array in /home/.../public_html/codebase/sites/all/modules/filefield/filefield_widget.inc on line 253.
- add another item button seems buggy - works ok for pressing it on the second row of a view adds an extra field input to the top row. if the top row had 2 or more blank extra rows added, this resets it back to 1.
- if i input say 4 values to the a field it works ok, but if i then refresh the view, i get 4 full field widgets displayed, each displaying the 4 inputs with their values and a blank input and the add more button.

So in general, things work quite well for the first row of a view but there are some bugs for subsequent rows. And when displaying the field in a view, multiple values in a field generate multiple instances of the widget, each displaying the multiple values of the field.

Hope this helps, thanks for your work on this module :)

Paul

andreiashu’s picture

hey everyone,
thanks a lot for the patches and testing. I'll have a look into this as soon as time permits.

Cheers,
Andrei

_paul_meta’s picture

Something worthy of note .. i've been trying to use the editview module as another possible workaround.

The bugs i mentioned about the add more button only adding extra fields to the first row of the view happen here too. So i think that might be a general cck issue - the script for multiple value fields seem to break when exposed in a view with multiple rows.

I also tried a similar thing with views_field_view and it seems any time a view outputs a field that is multi-value and has drag handles and the add another button, it breaks. row 1 is always fine, subsequent rows are buggy. the bugs i noticed are that the swap from drop downs for the drag value to drag handles doesn't happen, and when you click add another in anything other than the 1st row, the extra row is added to the first field and the subsequent field gets all its values. so in my testing reports of the patch, these issues seem to be not to do with editablefields module but a broader issue.

That might be something worth taking up with the cck maintainers as i think it will cause problems for modules like editview and editablefields creating a robust solution for the problem of exposing multi-value fields in views.

Thanks,

Paul

YesCT’s picture

as mentioned in comment #10, I too occasionally get the error
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /Users/me/sites/all/modules/filefield/filefield_widget.inc on line 255.

It happens when clicking on the remove button in a panel where there is a image field (single file only) using editablefields 3.x dev version

YesCT’s picture

#857938: Argument #2 is not an array in /sites/all/modules/filefield/filefield_widget.inc on line 255 might be of interest.
I think a null is being passed.
line 255 says: $item = array_merge($item, $file);
So I'm guessing $file is null after the "remove" button is clicked.

YesCT’s picture

#791118: warning: array_merge(): Argument #2 is not an array talks about a corrupted files table or something

YesCT’s picture

patch at #857938-3: Argument #2 is not an array in /sites/all/modules/filefield/filefield_widget.inc on line 255 made the warning not appear. I dont know if that is the actual best solution or not

_paul_meta’s picture

Seems that any multi-value field that is using a textfield/textarea/file widget will have some issues because of cck multi-value javascript. drag handles and add more button break as soon as there's more than 1 on screen. it would be great to see that become more robust for such situations as it affects cck as a whole, not just this module - seeing the same behaviour in other views modules that can expose edit widgets for multi-value fields.

checkbox widgets seem ok though. multi-value textfields and node reference fields that use checkboxes as their widget work great for me so far. still some issues with content taxonomy though. would be great if this could be fixed in this module as a first target.

i'm working on a complex cck/views project with as much editablefields as i can get working solidly so i'm happy to test any patches.

thanks :)

SocialNicheGuru’s picture

just noticed this on a client site.
I'll test too

joelpittet’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Last update was 2012, going to close as outdated because it's against 6.x branch.