Closed (fixed)
Project:
Examples for Developers
Component:
Form Example
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2010 at 06:19 UTC
Updated:
26 Dec 2010 at 07:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
rfayIn Drupal 6 imagefield is a CCK feature, and we try to do just core stuff. However, CCK is close to core :-)
Whenever possible, of course, one should use CCK/fields to do custom nodes. See also #794492: CCK custom field example
Comment #2
rfayI do think the Form Example needs a file upload, as that's a pretty obscure piece of art.
Comment #3
eojthebraveThe image_example module uses #managed_file and demonstrates it's use to upload files. Should be pretty easy to rip that off and include it in the form_example module.
Comment #4
googletorp commentedI created a patch for this. I didn't look at the image_example module, as I had just done something similar, only for a theme settings form instead of a node form.
There is an issue doing this in Drupal 6 with the node form because of #241364: $form_state not passed to hook_validate()/hook_node_validate(), and not passed by reference to hook_form(). The problem is basically that there's not a method with the FAPI to send the fid of the saved file along to the insert and update hooks. I solved this saving the fid in the user's session instead, and removing it again once the node has been saved/updated.
Anyways, take a look at it and let me know.
Comment #5
googletorp commentedUpdated patch to current and tweaked it a bit.
Do you have some ideas to how to test file uplaod? I haven't used the Drupal testing framework that much.
Comment #7
googletorp commentedUpdated the flaw in the patch.
Comment #9
googletorp commentedUps, try same patch formatted as CVS instead of git.
Comment #10
rfayComment #11
rfay@googletorp, I really apologize. In #2 I mistakenly put this as file_example, when I said in the text it should be added to form_example. I'm pretty sure form_example is where it belongs :-(
It can go in a separate inc file, which should use successfully what you've already done.
Comment #12
rfayJust noticed Upload Element project for D6, which may provide inspiration.
Comment #13
googletorp commentedI've been a bit more busy than I thought I would have been, but I finally was able to use the time needed to make this patch.
I recreated the patch for the form example. It was easier than trying to convert it anyways. I had some ready more code from a previous project that I could more or less c/p and add a few comments and tweaks.
Anyways for this patch I haven't added any tests. I'm not sure how to best do tests on fileuploads, if you have any pointers, I'll try to add some tests as well for the file upload.
Comment #14
rfayHi Googletorp!
For test ideas, take a look at the core test suites for file.module in D7. I think that might offer some good clues. Congratulations on getting this going.
Comment #15
googletorp commentedTests included. Let me know what you think.
Comment #16
rfayI'm teaching this week so won't get to review soon. @ilo - want to see what you think?
Comment #17
ilo commentedsure, later I'll do.
Comment #18
ilo commentedThank you so much both, googletrop and rfay, The example looks good, and I've done manual and automatic testing and works fine. The patch was wrong because it was not generated from the last -dev version, googletrop, where the element example turns the patch impossible to apply. Some tweakings has been done, the menu entry for the 11th is now in the right place.
Anyway, I've rerolled, forget about the cosmetic changes. It is committed to DRUPAL-6--1: http://drupal.org/cvs?commit=432268
Thanks again!
I've included the patch.
Comment #19
ilo commentedLets get this back again to live :)
Comment #20
googletorp commentedI ported the patch, after all I did check out D7 on how the tests was done.
Comment #21
googletorp commentedOpps, forgot to set status.
Comment #22
ilo commentedgoogletorp, thank you so much!!
unfortunatelly, before working on this, I guess it is better to have this other one: #870906: Explain #tree in element example (and rework Element Example!) commited, because rerolling would be hard due to its size.. That one is waiting for a serious review. In fact, there is a bug currently preventing the form testcase to case that is solved in the issue I mentioned.
keep the good work, as rfay sais!
Comment #23
rfay#20 passes now.
Comment #24
ilo commentedI changed my mind, and as long as the element example requires a major review (and probably rewrite) I think we can go on with this one first and then reroll the element example later.
Comment #25
rfayI'm ready to commit this, but having trouble with the testbots.
Comment #26
rfay#20: examples.form_example_upload_d7.831112.1.patch queued for re-testing.
Comment #27
rfay#20: examples.form_example_upload_d7.831112.1.patch queued for re-testing.
Comment #28
rfayCommitted: http://drupal.org/cvs?commit=463216
Thanks!