=============================== :mod:`formular.fields` - Fields =============================== This module provides the built-in fields. .. currentmodule:: formular.fields Basic Fields ------------ Fields representing basic types like strings, numbers etc. .. autoclass:: TextField :show-inheritance: :members: .. autoclass:: PasswordField :show-inheritance: :members: .. autoclass:: NumberField :show-inheritance: :members: .. class:: IntegerField FloatField DecimalField Fields representing the number types built-in to python or available in the standard library. Use :class:`NumberField` to represent any other type. .. autoclass:: BooleanField :show-inheritance: :members: .. autoclass:: SubmitField :members: .. autoclass:: ChoiceField :show-inheritance: :members: .. autoclass:: MultiChoiceField :show-inheritance: :members: .. autoclass:: ReCAPTCHAField :members: Date and Time Fields -------------------- .. note:: These fields require `Babel `_. .. autoclass:: TimeField :show-inheritance: :members: .. autoclass:: DateField :show-inheritance: :members: Collection Fields ----------------- Fields representing collections/datastructures. .. autoclass:: Multiple :show-inheritance: :members: .. autoclass:: Seperated :show-inheritance: :members: .. autoclass:: Mapping :show-inheritance: :members: Making Your Own Field Type -------------------------- Making your own field type is easy. You have to write a method which represents the value, the field represents as a string (:meth:`~Field.to_primitive`) and a method which converts this string back to the value (:meth:`~Field.convert`). If the unicode representation is enough to convert it you don't even have to implement :meth:`~Field.to_primitive`. In addition to that you can define a default value for the type, if :data:`formular.datastructure.missing` doesn't fit, add the validators (:attr:`~Field.validator_factories`) and the error messages (:attr:`~Field.error_messages`). However if there is already an abstract field implementing the behavior of the type you might not even have to add the validators and the error messages for those validators. Abstract Fields ^^^^^^^^^^^^^^^ Fields implementing the validators and error messages for values with the specified behavior. .. autoclass:: SizedField :show-inheritance: :members: .. autoclass:: ComparableField :show-inheritance: :members: The Field Base Class ^^^^^^^^^^^^^^^^^^^^ .. autoclass:: Field :members: