Re: QuickForm (QF): trouble with a group of 'file' elements and group rules

From: Date: Wed, 06 Dec 2006 20:56:42 +0000
Subject: Re: QuickForm (QF): trouble with a group of 'file' elements and group rules
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25994@lists.php.net to get a copy of this message
Hi, jam@zoidtechnologies.com wrote:
*please* CC me on any replies as I am not currently subscribed to the pear-general list. thank you. I have the following bit of code (with some things removed) that I am attempting to get working: -- begin code --- $form = new HTML_QuickForm("foo", "post", null, null, array("mimetype" => "multipart/form-data")); $form->addElement("header", "header", "example header"); $images = array(); for ($i = 0; $i < 10; $i++) {
    $images[] = &HTML_QuickForm::createElement("file", "", "Image {$i}");
} $form->addGroup($images, "images", "Images", "<br />"); $form->addGroupRule("images", "File size must be less than 512kilobytes", "maxfilesize", 512000); $form->addGroupRule("images", "File name must be *.jpg or *.jpeg", "filename", "/\.[jpg|jpeg]$/"); $form->addGroupRule("images", "File must be of type jpeg image", "mimetype", array("image/jpeg")); $form->addGroupRule("images", "File must be uploaded", "uploadedfile"); --- end code ---
I had a brief look through QuickForm code and doubt that will work at all, the getSubmitValue() method used by validate() isn't smart enough to return the proper value for 'images' in this case. :( You'll need to add the rules for each upload field separately.

« previous php.pear.general (#25994) next »