Quickform custom validation rule + validating file
| From: | Alexey Merkulove | Date: | Thu, 28 Oct 2004 15:19:51 +0000 |
| Subject: | Quickform custom validation rule + validating file | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-15189@lists.php.net to get a copy of this message | ||
Hello!
Thanks for great mechanism for webdevelopers. It is flexible but sometimes i
just come to some questions that i could not solve myself somehow, so this
is one of them:
If i have a custom rules in my form, how i supose to deal with files upload,
cause if i put something like this, it's not woking:
function ne_mod_validating($values)
{
if (empty($values['myfile']) && $values['mod']<0){
$errors['myfile'] =
'Error in file!';}
}
and even if i put before ny custom rule this line, it doesno work too:
$form->applyFilter('__ALL__', 'trim');
$form->addRule('myfile', 'file requried!',required);
$form->addRule('myfile', 'file must be smaller then 1 mb',
'maxfilesize',
10448576);
$form->addRule('myfile', 'Only jpeg *.jpeg is accepted',
'mimetype',
array('image/jpeg', 'image/pjpeg'));
$form->addFormRule('ne_mod_validating');
How should i check file & keep my custom rule cause it is some other tests i
have to make.
Thanks, Best regards
Alexey Merkulove