[Welcome] [TitleIndex] [WordIndex

Problem

How do we get the value of a variable from a submitted form?

Solution

There are several solutions.

The simplest is using get_field:

      from quixote import get_field

      def my_handler [html] (self):
          value = get_field('var_name_1')
          o
          o
          o

If you are using the Quixote 2 quixote.form package, you can reference the value of a widget in the form in the same way that you would reference a value associated with a key in a dictionary. Here is an example:

      myExampleForm = form.Form(name='my_example_form', action_url='finish')
      myExampleForm.add(form.StringWidget, 'user_name', '',
          title='User name:',
          hint='Enter your name (last, first). ',
          size=40,
          required=False)
      value = myExampleForm['user_name']
      o
      o
      o

Discussion

See UploadingFiles to see how to deal with uploaded files.


CategoryCookbook


2010-09-22 22:14