Re: Quickform, multiple upload problem
| From: | Mark Wiesemann | Date: | Mon, 19 Mar 2007 08:12:32 +0000 |
| Subject: | Re: Quickform, multiple upload problem | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-26874@lists.php.net to get a copy of this message | ||
Louie Miranda wrote:
> http://i32.photobucket.com/albums/d41/lmiranda723/qf_upload_problem.jpg
>
>
> That is what is being displayed using this code..
> $form->addElement('file', 'userfile[]', array('Upload file:',
> 'Rule types:
> \'uploadedfile\', \'maxfilesize\' with $format = 10240,
> \'mimetype\' with
> $format = \'text/xml\''));
> $form->addElement('file', 'userfile[]', array('Upload file:',
> 'Rule types:
> \'uploadedfile\', \'maxfilesize\' with $format = 10240,
> \'mimetype\' with
> $format = \'text/xml\''));
> $form->addElement('file', 'userfile[]', array('Upload file:',
> 'Rule types:
> \'uploadedfile\', \'maxfilesize\' with $format = 10240,
> \'mimetype\' with
> $format = \'text/xml\''));
>
> $form->addRule('userfile[]', 'Upload is required',
> 'uploadedfile');
>
> Im using multiple upload scheme on an array using userfile[], i was hoping
> to validate only the first userfile[], but when i use this approach. It
> tries to validate everything. :( .
That is because all elements have the same name.
> Would it be possible to validate only the first userfile[] and make
> the others optional?
Yes.
(If you also want to know the solution [you haven't asked for it *g*]:
Use names like 'userfile[0]', 'userfile[1]' and 'userfile[2]'. The
resulting array won't change, but you can assign the rule now to only
one element.)
Regards,
Mark
--
http://www.markwiesemann.eu