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.
Trying to use flexinode to upload files to the server, but each time the system returns to the page with the message:
You must fill in the field "File".
("File" is the lable given to the 'file' field)
It seems like it is not recognising that a file was selected. Nothing is added to the database.
Comment | File | Size | Author |
---|---|---|---|
#14 | flexinode.patch_3_0.txt | 1.24 KB | Bèr Kessels |
Comments
Comment #1
scroogie CreditAttribution: scroogie commentedHad the same issue with Images. If i recall correctly the problem was the call to file_save_upload() in flexinode_field_image_insert(), because it was already called in flexinode_field_image_execute(). Try commenting out this line in insert().
Comment #2
gmak CreditAttribution: gmak commentedThat doesn't seem to be the case here. "flexinode_field_file_insert()" doesn't have the same call as "flexinode_field_file_execute()". There is only one file_save_upload called (and that is in "flexinode_field_file_execute()".
Any other suggestions?
Comment #3
scroogie CreditAttribution: scroogie commentedDoes it work if you replace variable_get('file_directory_path', NULL) with file_directory_path()? That seems to be the only difference to field_image.inc
Comment #4
gmak CreditAttribution: gmak commentedIf I've followed your suggestion correctly and changed:
variable_get('file_directory_path', NULL)
to
variable_get('file_directory_path()', NULL)
then the answer is no, it still doesn't work.
I can attach files (using the attachment.module) and upload images using img_assist.module and image.module, so I don't think it is an issue with my setup. The problem must be somewhere in flexinode.
Any other ideas?
(By the way, thanks for helping sort this out ... if we can sort it out)
Comment #5
gmak CreditAttribution: gmak commentedI might be getting closer. What I find is that if I uncheck the "Required field" checkbox in the content type setting for the 'File' field, the uploading works. So, the problem is somewhere in the field validation which checks this field.
Can anyone suggest where I might be able to find a way to solve that?
Thanks,
Comment #6
cooperaj CreditAttribution: cooperaj commentedI have this exact same issue. Will have a look at the validation code but I can't promise that i'll find anything.
In the meantime I'll take out the required selection.
Comment #7
cooperaj CreditAttribution: cooperaj commentedAfter a very cursory look it seems that 'field_file.inc' does not have a flexinode_field_file_validate()' function. So when the validate hook is called it does not get to return a correct value. I'm assuming this results in a 'false' return and so prompts the user.
I'll try to implement the function.
Comment #8
cooperaj CreditAttribution: cooperaj commentedI was wrong. Adding a validate function did nothing.
Doing a print_r($node) on the entrance to flexinode_validate($node) shows that the item it checks is indeed empty. I don't know why it is empty and I'm not sure how the whole validate/execute thing works anyway so I'm going to have to leave this for a short while.
Hopefully this can be resolved.
Comment #9
chud CreditAttribution: chud commentedI would love to know if anyone has been able to resolve this! I have a project that needs 'required' image fields.
I've tried to debug the code to figure out what's wrong, but I'm pretty much at a loss. As far as I can tell the $node object that is used in flexinode_validate() is incomplete. In my case the image field is known as flexinode_8. $node->flexinode_8 is always NULL. However, normally $node->flexinode_8 contains more information such as $node->flexinode_8->thumbpath for instance.
Any solution that would enable me to have required image fields in my flexinodes would be great!
Here is another post about the same issue: http://drupal.org/node/54061
Thanks!
PS- I'm using 4.7 with Flexinode CVS
Comment #10
samc CreditAttribution: samc commentedWow, what a way to kill an evening ;-)
To recap: The upload mechanism is working fine. Problem is in validation when the field is required.
Turns out, even if you get past flexinode_validate() in flexinode.module, the form is rejected by the validation routine in core. (_form_validate in form.inc).
Bottom line seems to be that both validation routines are looking for the (required) form field to have a value, and the "file" field type does not return a value.
I tried (albeit, a 1:00 am try) to implement a custom validation routine using #validate in the form, but this doesn't seem to _override_ the validation in core, just offers a place to insert additional checks.
I don't see an easy way around these issues, so looking to more experienced drupal folks to advise.
Comment #11
samc CreditAttribution: samc commentedBèr posted an issue to core about this issue:
Comment #12
samc CreditAttribution: samc commentedA value can be 'spoofed' by manually setting it in the form like so:
This will get the field to validate, but I'm not sure it's a supported use of the #value element. Unlike the case in [1], here it's tagging along on a form control of type 'file' (not type 'value'). According to the form api reference[2], this isn't supported.
This is only a partial victory, because if the preview button is used the value in the form field is lost. This isn't related to the approach above, just the fact that the full path isn't available to the server. (This might be client specific, but stuff I've seen[3] suggests that the server shouldn't expect to see the path.)
So, a possible solution is to use some javascript to copy the filepath from the file field to a hidden field on submit, and place that back into the form using the #default_value property when building the form the second time around. Seems resonable, but as of right now, the #default_value property isn't working for controls of type 'file'[4].
I have no idea how to do the javascript stuff in a Drupal-like way, so I'm hoping someone who knows that stuff can chime in.
Was this--namely having the value available after preview--working prior to the 4.7 updates?
Perhaps a look at upload.module is in order?
[1] http://drupal.org/node/54215
[2] http://api.drupal.org/api/HEAD/file/developer/topics/forms_api_reference...
[3] http://www.codecomments.com/archive227-2004-10-305251.html
[4] http://drupal.org/node/60046
Comment #13
samc CreditAttribution: samc commentedPer http://drupal.org/node/59750, looks like core developers are tabling this issue until post 4.7 release.
For now, required flag on file fields is not supported.
We can continue to use this thread to post workarounds/patches.
Comment #14
Bèr Kessels CreditAttribution: Bèr Kessels commentedhttp://drupal.org/node/60972 was marked duplicate of this issue. It contains a patch too. reattaching that here, for reference.
Comment #15
cooperaj CreditAttribution: cooperaj commentedThis has been open a looong time. Does the patch still apply? Is flexinode maintained?
I'd like to close this call. I'll leave it a week and come back and close it then.
Comment #16
samc CreditAttribution: samc commentedCan't answer either of those, but I'm no longer actively working this issue so unassigning.
Comment #17
quicksketchFlexinode has long been abandoned. This is being fixed in Drupal core in #59750: Required flag on file forms breaks on validation.