.. _ref-vc-forms-fields: =========== Form fields =========== .. module:: kiowa.vcl.forms.fields :synopsis: Kiowa form fields addons. .. currentmodule:: kiowa.vcl.forms Built-in ``Field`` classes -------------------------- Naturally, the ``forms`` library comes with a set of ``Field`` classes that represent common validation needs. This section documents each built-in field. For each field, we describe the default widget used if you don't specify ``widget``. We also specify the value returned when you provide an empty value (see the section on ``required`` above to understand what that means). ``JQModelChoiceField`` ~~~~~~~~~~~~~~~~~~~~~~ .. class:: JQModelChoiceField(ajax_service, **kwargs) E' l'equivaliente del ModelChoiceField standard di Django. Un unico parametro รจ obbligatorio .. attribute:: ModelChoiceField.ajax_service Un riferimento ad un ``AjaxService`` opportunamente configurato. ``CharField`` ~~~~~~~~~~~~~ .. class:: CharField(**kwargs) * Default widget: ``TextInput`` * Empty value: ``''`` (an empty string) * Normalizes to: A Unicode object. * Validates ``max_length`` or ``min_length``, if they are provided. Otherwise, all inputs are valid. * Error message keys: ``required``, ``max_length``, ``min_length`` Has two optional arguments for validation: .. attribute:: CharField.max_length .. attribute:: CharField.min_length If provided, these arguments ensure that the string is at most or at least the given length. ``DateField`` ~~~~~~~~~~~~~ .. class:: DateField(**kwargs) * Default widget: ``DateInput`` * Empty value: ``None`` * Normalizes to: A Python ``datetime.date`` object. * Validates that the given value is either a ``datetime.date``, ``datetime.datetime`` or string formatted in a particular date format. * Error message keys: ``required``, ``invalid`` Takes one optional argument: .. attribute:: DateField.input_formats A list of formats used to attempt to convert a string to a valid ``datetime.date`` object. If no ``input_formats`` argument is provided, the default input formats are:: '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06' '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006' '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006' '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006' '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' .. versionchanged:: 1.1 The ``DateField`` previously used a ``TextInput`` widget by default. It now uses a ``DateInput`` widget.