Field types

Albatross forms defines a number of standard fields. They are:

  1. TextField

  2. PasswordField

    • Same as a text field but it doesn't display the characters as the user enters them.
  3. StaticField

  4. TextArea

  5. IntegerField

    • An integral value, get_value() will return an int type.

  6. FloatField

    • A floating point value, get_value() will return a float type.

  7. Checkbox
    • As expected, get_value() will return a Boolean type.

  8. SelectField

    • Returns one of the values listed in the (value, display_value) list passed to the constructor. If the value can be converted to an int, it will be; otherwise it will be returned as a string.

  9. FileField (XXX not implemented (yet))

Internal storage within a field

The interaction of the field with the browser is complicated because the browser requires and returns string values. That loses the type of the objects that the fields wrap.

To manage this, the field class notes when the field is rendered to the browser and converts the value to a string using the object's get_display_value method. When the values are posted back to the form by the browser, they are stored as strings. If you need to access the value stored in a field, use the get_value() method which tracks the type of the stored representation and does a conversion (using get_merge_value) when appropriate.

None: Field_types (last edited 2011-02-15 06:05:17 by localhost)