[development] Forms API and #required file fields

Darrel O'Pry dopry at thing.net
Fri Jun 2 21:47:08 UTC 2006


On Fri, 2006-06-02 at 23:14 +0200, Adrian Rossouw wrote:
> On 02 Jun 2006, at 7:16 PM, Barry Jaspan wrote:
> 
> > The Forms API does not currently support file fields with #required  
> > => TRUE (and is documented as such in the Forms API Reference).  I  
> > suggest that with a little effort it can and that to make the API  
> > more consistent and useful it should.
> quite frankly. the implementation of the file field needs to be  
> completely redone.
> 
> The issue with the file field is that it provides the input, but it  
> never has a value, hence FAPI has nothing to validate the required  
> against.
> 
> The only thing it can even remotely handle at the moment is if you  
> have uploaded a file in the previous request. As each of the modules  
> that implement
> the file field implement the back end handling differently, it's a  
> lost cause.
> 
> What really needs to happen is that all the magic that happens in  
> upload.module needs to become part of the file field. The files table  
> needs a secondary 'realm' key,
> and you need to be able to upload a file simply by adding a file  
> field, with a realm, and optionally a unique identifier (node id,  
> user id, whatever)
> 
> To do this in the form layer is no simple task however, since we lack  
> context. Also, all the preview stuff , and not having a proper id at  
> the right time, makes all
> this stuff far more complex than it should be. =(

I've been working on filesystem.module... Its primarily a scratch space
where I can work out what I think the file handling should be. 

It solves several problems by removing the nid field from the files
table and using the uid...

It also provides a form #type of filesystem_file which does all the
upload black magic.

currently you can upload a file with it.

I'm looking for people interested in developing it with me. Things I
really want are 

1) a complete set of simpletests (any takers? I've made the
skeletons.. ) for both the low level api, and the module. 

2) people to give me feedback on how I'm implementing filehandling.

.darrel.



> --
> Adrian Rossouw
> Drupal developer and Bryght Guy
> http://drupal.org | http://bryght.com
> 
> 
> 



More information about the development mailing list