I'm using multiforms with organic groups and media module. By assigning a group audience field to a media file entity, you can start to associate uploaded files with groups. Multiform plays a role in the media module by allowing you to modify the fields of several uploaded files in one form; it works well for text fields, dates, everything except group audience.

I found the problem which I believe is associated with the $_POST that is be created after the submit button is pressed on the multi-edit form. You can see in the dpm output that group audience lies outside the 'multiform' array which is causing the problem. I tried to trace back to where the $_POST is being generated but cannot find where.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ejsteven’s picture

Assigned: ejsteven » Unassigned
Kazanir’s picture

This appears to be a more generalized issue with setting any sort of custom field values on File Entities, but I have no idea if the bug lies in this module or File Entity's assembling of their normal edit form. All I know is I can't add taxonomy terms to a file via the multiform edit screen and Hierarchical Select breaks on it also.

Kazanir’s picture

With help from davereid and rootatwc in #drupal-media we have tracked this down to an unhandled case in multiform.module. <select> form elements with multiple values don't use the ['#name'] attribute that most fields do, but rather take their HTML name from a ['#attributes']['name'] setting in the form array. Multiform's re-naming recursion function uses element_children(), which doesn't reach into #attributes array and only looked for ['#name'] and not ['name']. Patching the module to manually look into a #attributes array and look for any ['name'] elements (just in case) solves this issue as in the attached patch.

Dave Reid’s picture

Status: Active » Needs work

I'm curious if this works if we remove the section that applies to $element['name'] since that shouldn't be a string since it doesn't start with a '#' and would instead be covered by the recursion in the function. Basically, if we were to just add the chunk that processes $element['#attributes']['name'] does this fix the issue?

Dave Reid’s picture

Title: Organic Group Fields Cannot Be Set » Elements with name property set in attributes not adjusted for multiforms (missing values on submit)
Kazanir’s picture

Yeah in this case it would solve the issue. I only added it because I'm not familiar with the Form API and figured that if ['#attributes']['name'] can appear, then ['name'] might appear on a recursed element directly.

mstef’s picture

#3 works. Prior to using that patch, select fields did not work on multiforms.

pglynn’s picture

+1 for #3. This allowed me to add multi-select boxes on multiple edit forms produced by Media Browser Plus and Media modules.

Kazanir’s picture

Please be advised that various other non-standard multi-selection widgets break on Multiform, notably Hierarchical Select and Multi-select. I haven't had the time (nor do I truly have the expertise) to track down why, but it is highly relevant for anyone using multi-valued select fields on file entities along with this module and Media/File Entity.

gmclelland’s picture

I tried the patch in #3 with the latest file and media-2.x-dev versions, but I get the following errors many times when I try the following:
1. Go to the document file type
2. Add the following fields
-- Year - term reference - select
-- Topics - term reference autocomplete - unlimited
-- Cover Image - Type=image, Widget=image
3. Go to file/add
4. Using the plupload module, select three files
5. You receive the notices and all files and fields are displayed for editing
Notice: Array to string conversion in _multiform_get_form() (line 145 of /Users/glenn/Sites/acquia-drupal/sites/mediatest.localhost/modules/multiform/multiform.module).

6. Click Save
7. Errors
Fatal error: Call to undefined function file_entity_edit_validate() in /Users/glenn/Sites/acquia-drupal/includes/form.inc on line 1460
8. Check admin/content/file - files are uploaded by the everything that was entered into the fields was not saved.

gmclelland’s picture

Ok, this is weird. On a site with just the latest 2.x-devs of media and file_entity, multiform, and plupload, I can upload 1 image and 2 pdf files at file/add and everything works fine. Files are saved with their field data that I entered.

Now if go to file/add and upload 2 pdfs, I get the following error:
Fatal error: Call to undefined function file_entity_edit_validate() in /Users/glenn/websites/7c9d097f-0bc1-457d-8314-1d9e37f102bf/includes/form.inc on line 1464
The files were uploaded but no field data was saved.

The document file type has the following fields
-- Title - text field - required
-- Year - term reference - select
-- Topics - term reference autocomplete - unlimited
-- Cover Image - Type=image, Widget=image

The image file type has the following fields
-- Tags - Term reference - autocomplete

jdidelet’s picture

Attached a patch who correct the bug related to the Notice error. It's based on the #3 patch. Tested on:
file_entity: 2.x-dev
media: 2.x-dev
multiform: 1.0
plupload: 1.2

And with an entity reference field with multiple values option.

gmclelland’s picture

@jdidelet - Thanks for the patch but it still throws an error when I try to add multiple files at file/add. It also has a whitespace error.

Fatal error: Call to undefined function file_entity_edit_validate() in /Users/glenn/websites/7c9d097f-0bc1-457d-8314-1d9e37f102bf/includes/form.inc on line 1464

gmclelland’s picture

Note: with the patch in #12, I didn't get any notice like I did in #10 but I still got the fatal error.

jdidelet’s picture

I didn't check for the other bug because I don't have this one. Perhaps it's related to the fields type you have. Can you try to test one by one the field type and check the result? On my current situation, I have entity reference and textfield field type.
I tried on my side with 1 image and 2 pdfs or only 2 pdfs and it's working. I don't have this error message.

Are you've using the same config? Me, I'm using:
file_entity: 2.x-dev
media: 2.x-dev => with patch http://drupal.org/files/media-permission_check_multiple_upload-1870538-3...
multiform: 1.0
plupload: 1.2

gmclelland’s picture

@jdidelet - just tried with that patch you mentioned. I'm running the same modules.

If interested, my field setup is explained in #11

Even with those modules patched, I still get the same Fatal error.

gmclelland’s picture

Issue summary: View changes

Fixed typo.

MiroslavBanov’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.56 KB

Had the same issue - multiple values term reference field in file entity. Patch #12 does fix the problem for me.
Other than that, as per #4, element['name'] is a different render element, so it shouldn't be checked in its parent. I've updated the patch to reflect that.

gmclelland’s picture

I think my problem(the fatal errors) in #11 is solved with the patch in #2142375: Fatal error when adding 2 pdfs at file/add with media, multiform, and plupload

Also the patch provided in #17 is working for me.

gmclelland’s picture

For what it is worth, I upgraded to the latest dev of multiform and I'm not seeing these problems anymore.

MiroslavBanov’s picture

@gmclelland

I used the patch with revision 326474f29f359beea2235bdcdd89accdaa8c88f9
Since that revision, there are only three commits and looking at the diff, they don't look like they could fix these problems.
Maybe we need to come up with clear steps to reproduce. Or a test.

gmclelland’s picture

@MiroslavBanov - Yah, I couldn't remember the steps to reproduce this other than my older comments in #10 and #11.

My fatal errors seem to be fixed with the latest patch in #2142375: Fatal error when adding 2 pdfs at file/add with media, multiform, and plupload.

What kind of errors are you seeing?

MiroslavBanov’s picture

Can't check right now. Will get back to this later and provide more detailed steps.

Andrew Edwards’s picture

Here's the patch from #17 against the latest dev

dieuwe’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch, it works great with an entityreference field that allows multiple selections.

fenstrat’s picture

Also confirming #23 is RTBC.

Use case: media_gallery-7.x-1.x with a select list field added to the image file type. Without #23 any submitted values for the select list are not saved.

johnennew’s picture

Patch in #23 works correctly.

joseph.olstad’s picture

Status: Reviewed & tested by the community » Fixed

committed to 7.x-1.x dev branch
this is NOT in 7.x-1.2 , its in 7.x-1.x dev. It will be in 7.x-1.3 at some point.

Status: Fixed » Closed (fixed)

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