[development] Forms API and #required file fields

Adrian Rossouw adrian at bryght.com
Fri Jun 2 21:14:46 UTC 2006


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. =(



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




More information about the development mailing list