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

From: Date: Wed, 06 Dec 2006 16:02:27 +0000
Subject: Re: Re: QuickForm (QF): trouble with a group of 'file' elements and group rules
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-25987@lists.php.net to get a copy of this message
(note I am now subscribed to the mailing list, so an explicit cc is not necessary) On Wed, Dec 06, 2006 at 07:56:15AM +0100, Mark Wiesemann wrote: > jam@zoidtechnologies.com wrote: > > > I have the following bit of code (with some things removed) that I am > > attempting to get working: > > > > -- begin code --- [..snipped..] > > --- end code --- > > Just a quick guess after a quick look on your code: You should try to > specify the $howMany parameter which defaults to 0 (which then might be > the reason for your form to be valid). > ok.. I changed my code so that it uses the $howMany parameter (which I did not see much explanation of in the docs, btw-- just that it exists). anyways, here's my code, which still allows "gif" images to pass through despite the rules I've set up: --- begin code --- $form = new HTML_QuickForm("sample", "post", null, null, array("mimetype" => "multipart/form-data")); $form->addElement("header", "header", "sample"); $images = array(); for ($i = 0; $i < 10; $i++) { $images[] = &HTML_QuickForm::createElement("file", null, "Image {$i}"); } $form->addGroup($images, "images[]", "Images", "<br />"); $form->addGroupRule("images[]", "File name must be *.jpg or *.jpeg","filename", "/\.[jpg|jpeg]$/", 10); $form->addGroupRule("images[]", "File must be of type jpeg image","mimetype", array("image/jpeg"), 10); $form->addGroupRule("images[]", "File must be uploaded", "uploadedfile",10); $buttons = array(); $buttons[] = &HTML_QuickForm::createElement("submit", null, $mode); $buttons[] = &HTML_QuickForm::createElement("reset", null, "reset"); $form->addGroup($buttons); $form->setMaxFileSize(524288); --- end code --- I tried a couple different versions of this code, specifically changing the 2nd argument of addGroup() to "images" and then to "images[]" neither of which change the way things are running. perhaps I'm using the $howMany incorrectly? my goal is to not "require" any of the images (thus no "required" rules in the above), but if anything is in any of the 10 fields, I'd like QF to be certain they all pass the rules I have set up. so far it sails right through. > Regards, > Mark > thank you for your reply, Mark :) I'm looking forward to getting this resolved. regards, J

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