Quickform fileupload->filename and numeric rule
| From: | Fredrik de Vibe | Date: | Wed, 19 Mar 2003 04:10:30 +0000 |
| Subject: | Quickform fileupload->filename and numeric rule | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-4293@lists.php.net to get a copy of this message | ||
To start off, I have to say it is a truly great package. It really
makes life a whole lot easier.
I've been using QuickForm for about a week now, and there are two
things I'm missing. I might have overlooked something, but here goes.
The first is easy to add manually, but I thought it might be worth
mentioning nonetheless.
At least in Norway, the zip codes all have four digits, but the first
one(s) can be 0. Therefore, the 'numeric' rule along with 'maxlength'
and 'minlength' don't quite do the trick.
I added the rule
$form->registerRule('numericlength', 'regex',
'/^[0-9]{%data%}$/');
which doesn't take into account the integer value, just makes sure
that the field only contains digits, and a specified number of them.
The second is also possible to work around, but as far as I can see,
this is not a very good way to do things. There is a function for
retrieving the tmp_name of an uploaded file, but as far as I can see
not the original file name.
True, this can be accomplished by accessing the value
$form->_submitFiles["file"]["name"];
but are the '_'-variables meant to be accessed like this?
I might be wrong here, and these issues are not difficult to solve,
but as I said, I thought they were worth mentioning. :-)
--
--Fredrik