formish.widgets¶
Commonly needed form widgets.
- class formish.widgets.Input(**k)¶
Bases: formish.widgets.Widget
Basic input widget type, used for text input
- convert(schema_type, request_data)¶
- Default to stripping whitespace
- class formish.widgets.Password(**k)¶
Bases: formish.widgets.Input
Password widget is a basic input type but using password html input type
- class formish.widgets.CheckedPassword(**k)¶
Bases: formish.widgets.Input
Checked Password ensures that the password has been entered twice
- convert(schema_type, request_data)¶
- Check the password and confirm match (when stripped)
- pre_render(schema_type, data)¶
- Extract both the password and confirm fields
- class formish.widgets.Hidden(**k)¶
Bases: formish.widgets.Input
Basic input but using a hidden html input field
- class formish.widgets.TextArea(**k)¶
Bases: formish.widgets.Input
Textarea input field
Parameters: - cols – set the cols attr on the textarea element
- rows – set the cols attr on the textarea element
- convert(schema_type, request_data)¶
- We’re using the converter options to allow processing sequence data using the csv module
- pre_render(schema_type, data)¶
- We’re using the converter options to allow processing sequence data using the csv module
- class formish.widgets.Checkbox(**k)¶
Bases: formish.widgets.Widget
Checkbox widget, defaults to True or False
- convert(schema_type, request_data)¶
- If the request data exists, then we treat this as True
- class formish.widgets.DateParts(**k)¶
Bases: formish.widgets.Widget
Simple three part date entry form
- convert(schema_type, request_data)¶
- Pull out the parts and convert
- pre_render(schema_type, data)¶
- Convert to date parts
- class formish.widgets.FileUpload(filehandler, show_image_preview=False, allow_clear=True, css_class=None, originalurl=None)¶
Bases: formish.widgets.Widget
File upload widget.
Parameters: - filehandler –
filehandler is any object with the following methods:
- storeFile(self, f)
- where f is a file instance
- getUrlForFile(self, data)
- where data is the form item data or a path to a temporary file and is expected to return a URL to access the persisted or temporary data.
- show_image_preview – a boolean that, if set, will include an image thumbnail with the widget
- css_class – extra css classes to apply to the widget
- originalurl – a default url to
- convert(schema_type, request_data)¶
- Creates a File object if possible
- pre_parse_request(schema_type, data, full_request_data)¶
- File uploads are wierd; in out case this means assymetric. We store the file in a temporary location and just store an identifier in the field. This at least makes the file look symmetric.
- pre_render(schema_type, data)¶
- We use the url factory to get an identifier for the file which we use as the name. We also store it in the ‘default’ field so we can check if something has been uploaded (the identifier doesn’t match the name)
- filehandler –
- class formish.widgets.SelectChoice(options, none_option=<object object at 0x940b4e0>, css_class=None)¶
Bases: formish.widgets.Widget
Html Select element
Parameters: - options – either a list of values [value,] where value is used for the label or a list of tuples of the form [(value, label),]
- none_option – a tuple of (value, label) to use as the unselected option
- css_class – a css class to apply to the field
- get_none_option(schema_type)¶
- Get the default option (the ‘unselected’ option)
- get_options(schema_type)¶
- Return all of the options for the widget
- selected(option, value, schema_type)¶
- Check the value passed matches the actual value
- class formish.widgets.SelectWithOtherChoice(options, none_option=<object object at 0x940b4e0>, other_option=<object object at 0x940b4e0>, css_class=None)¶
Bases: formish.widgets.SelectChoice
Html Select element
- convert(schema_type, request_data)¶
- Check to see if we need to use the ‘other’ value
- get_other_option(schema_type)¶
- Get the other option
- pre_render(schema_type, data)¶
- populate the other choice if needed
- selected(option, value, schema_type)¶
- Check the value passed matches the actual value
- class formish.widgets.RadioChoice(options, none_option=<object object at 0x940b4e0>, css_class=None)¶
Bases: formish.widgets.Widget
Radio choice html element
- convert(schema_type, request_data)¶
- If we don’t have a choice, set a blank value
- selected(option, value, schema_type)¶
- Check if the currently rendering input is the same as the value
- class formish.widgets.CheckboxMultiChoice(options, css_class=None)¶
Bases: formish.widgets.Widget
Checkbox multi choice is a set of checkboxes that for a sequence of data
- checked(option, values, schema_type)¶
- For each value, convert it and check to see if it matches the input data
- convert(schema_type, request_data)¶
- Iterating to convert back to the source data
- pre_render(schema_type, data)¶
- Iterate over the data, converting each one
- class formish.widgets.SequenceDefault(**k)¶
Bases: formish.widgets.Widget
Sequence handling widget - used by default for schema sequences
Parameters: - min – minimum number of sequence items to show
- max – maximum number of sequence items to show
- addremove – boolean whether to show the addremove buttons (jquery activated)
- pre_render(schema_type, data)¶
- Short circuits the usual pre_render