Allow posting duplicate form-name entries with different values
6th September 2006
Sometimes, writing automatic HTML forms processors, you need to post several values with the same name of the form field, e.g.:
collection_gene = str_chrom_name
collection_gene = gene_stable_id
This is against the RFC on form fields design and submitting, but this approach is used – for example, by Ensembl. I spent some time to figure out how to make HTTP_Client and HTTP_Request submit multiple ‘name-value’ pairs instead of one (the latest defined, which overrides the previous). The solution is extremely simple:
- /*
- allow posting duplicate form-name
- entries with different values
- */
- $params['useBrackets'] = false;
- $req = &new HTTP_Client($params, $headers);
After setting ‘useBrackets’ parameter to ‘false’, HTTP_Client/HTTP_Request do post multiple lines as you would want it.
Hope this saves you some time.