Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    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:

    1. /*
    2.  allow posting duplicate form-name
    3.  entries with different values
    4. */
    5. $params['useBrackets'] = false;
    6. $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.

    Share

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>