Re: Select multiple boxes

From: Date: Mon, 20 Jan 2003 18:31:31 +0000
Subject: Re: Select multiple boxes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-132281@lists.php.net to get a copy of this message
John W. Holmes wrote:
use [] in your select box name. When it comes back in the $_POST array you will have an array of options. It breaks HTML standard
No, it does not break HTML standards -- that is a PHP urban myth
(which,
to
my chagrin, I helped to propagate before a wiser head sent me to
read
said
standards in minute detail). It does not even break XHTML
standards.
Believe me -- I've interrogated the damn standards to within an inch
of
their lives, and they nonetheless insist that [] are legal
characters in
form element name= attributes, and form element name= attributes are
*not*
deprecated.
while I agree that it doesn't break standards - I do find it odd. and annoying in that it limits the ability of php to process certain forms ... I don't see any benefit of this system - it would be better if php
just
created an array for suitable form data - without requiring that the element name changes.
How does php know what "suitable form data" is? I guess it could look for multiple names in the GET or POST data. But then that would mean for every variable it goes to create, it would have to go and look if it's already created one by that name. If it did, erase the old one and make these two an array now. Rather than doing that, it can just look for [] in the name and it knows to make that an array.
well I think you answered your own query - it could look for multiple names ... this seems to work well in other systems - eg Perl:CGI and Java Servlets - though as these have seperate types for an array - so it works quite naturally there. in fact I have only seen this construct in php - it seems odd to me. I have worked on several projects where forms have been used to communicate between systems under the control of different development teams - in this case the requirement to rename the form element for it to work as a select multiple has been a pain. -- Sean

« previous php.general (#132281) next »