type of form field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ajar

    #1

    type of form field

    Is there any way to retrieve the type(checkbox,r adio...) of the form
    field from cgi.FieldStorag e. I tried something like form['name'].type,
    but this field seems to be None for all the form fields

  • Mike Meyer

    #2
    Re: type of form field

    "Ajar" <ajartaknev@gma il.com> writes:[color=blue]
    > Is there any way to retrieve the type(checkbox,r adio...) of the form
    > field from cgi.FieldStorag e. I tried something like form['name'].type,
    > but this field seems to be None for all the form fields[/color]

    There isn't. cgi.FieldStorag e parses data sent via an HTTP
    request. The type of the input element isn't part of the data sent in
    an HTTP request. So not only is there no way to get it from
    cgi.FieldStorag e, there's no way to get it from any HTTP handling
    facility, unless it gets stored somewhere outside the element in
    question for you to retrieve.

    While you do have to store it outside the element, you don't have to
    store it outside the form. You could create a series of hidden input
    elements with names "foo.type" whose value was the type of the element
    foo. If your pages are dynamically generated, you could create a
    dictionary mapping element names -> types, and then pickle that and
    store the results in a hidden element. Or - well, I'm sure you get the
    idea.

    <mike
    --
    Mike Meyer <mwm@mired.or g> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.

    Comment

    Working...