Re: square brackets in form names violate HTML specs?

From: Date: Sun, 14 Sep 2003 15:41:16 +0000
Subject: Re: square brackets in form names violate HTML specs?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-162560@lists.php.net to get a copy of this message
Curt Zirzow wrote:
* Thus wrote Robert Cummings (robert@wocmud.org):
On Sat, 2003-09-13 at 17:21, Eugene Lee wrote:
On Sat, Sep 13, 2003 at 06:15:29PM +0000, Curt Zirzow wrote: : * Thus wrote Eugene Lee (list-php@fsck.net): : > Something I've noticed in PHP is a proliferation of code like this: : > : > <input name="stuff[title]" value="" type="text" size="40"> [...] : The way to properly do it would be to set set your name as: : : <input name="stuff%5Btitle%5D" value="" type="text" size="40"> Great idea, thanks Curt!
I almost fell for this and updated my code. Then I decided to read the spec for myself and noticed that it doesn't say anywhere that % is ok either *grin*. - ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
Yeah I sort of ignored that :) What is interesting though is that the html spec isn't fully supporiting HTTP. This probably should be changed to allow urlencoded characters. Although I do see the justification for this document.forms[0].stuff[title].value or document.forms[0].stuff%5Btitle%5D.value just wont work
Kind of supports the idea that PHP should turn multiple variables into an array automatically, without the need of specifying [ and ]. That would kill the ability of "name" keys in the HTML, though... <input type="text" name="name[xxx][yyy]" value=""> I like being able to do that and don't really care if it doesn't conform to the HTML spec... oh well. :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#162560) next »