Module reahl.web.bootstrap.forms¶
New in version 3.2.
Bootstrap-styled versions of Forms, Inputs and related Layouts.
Forms and their layout¶
Form¶
-
class
reahl.web.bootstrap.forms.
Form
(view, unique_name, rendered_form=None)¶ A Form is a container for Inputs. Any Input has to belong to a Form. When a user clicks on a Button associated with a Form, the Event to which the Button is linked occurs at the server. The value of every Input that is associated with the Form is sent along with the Event to the server.
Parameters: - view – (See
reahl.web.fw.Widget
) - unique_name – A name for this form, unique in the UserInterface where it is used.
- view – (See
NestedForm¶
-
class
reahl.web.bootstrap.forms.
NestedForm
(view, unique_name, css_id=None)¶ A NestedForm can create the appearance of one Form being visually contained in another. Forms are not allowed to be children of other Forms but this restriction does not apply to NestedForms.
Parameters: - view – (See
reahl.web.fw.Widget
) - unique_name – (See
Form
) - css_id – (See
HTMLElement
)
- view – (See
FormLayout¶
-
class
reahl.web.bootstrap.forms.
FormLayout
¶ A FormLayout is used to create Forms that have a consistent look by arranging all its Inputs, their Labels and possible validation error messages in a certain way.
This basic FormLayout positions Labels above added Inputs and allow for an optional helpful text message with each input.
Different kinds of FormLayouts allow different kinds of arrangements.
Different FormLayouts can be used on different sub-parts of a Form by composing a Form of Divs of FieldSets that each use a different FormLayout.
-
add_input
(html_input, hide_label=False, help_text=None)¶ Adds an input to the Form.
Parameters: - html_input – The Input to add.
- hide_label – If True, makes the label invisible yet available to screenreaders.
- help_text – Helpful text to display with each Input field.
-
InlineFormLayout¶
-
class
reahl.web.bootstrap.forms.
InlineFormLayout
¶ A FormLayout which positions all its Inputs and Labels on one line. The browser flows this like any paragraph of text. Each Label precedes its associated Input.
GridFormLayout¶
-
class
reahl.web.bootstrap.forms.
GridFormLayout
(label_column_size, input_column_size)¶ A GridFormLayout arranges its Labels and Inputs in a grid with two columns. Labels go into the left column and Inputs into the right column. The programmer specifies how wide each column should be.
Parameters: - label_column_size – A
ResponsiveSize
for the width of the Label column. - input_column_size – A
ResponsiveSize
for the width of the Input column.
- label_column_size – A
FieldSet¶
-
class
reahl.web.bootstrap.forms.
FieldSet
(view, legend_text=None, css_id=None)¶ A visual grouping of HTMLElements inside a Form.
Parameters: - view – (See
reahl.web.fw.Widget
) - legend_text – If given, the FieldSet will have a Legend containing this text.
- css_id – (See
reahl.web.ui.HTMLElement
)
- view – (See
Inputs¶
TextArea¶
SelectInput¶
-
class
reahl.web.bootstrap.forms.
SelectInput
(form, bound_field)¶ An Input that lets the user select an
reahl.component.modelinterface.Choice
from a dropdown list of valid ones.Parameters:
RadioButtonInput¶
-
class
reahl.web.bootstrap.forms.
RadioButtonInput
(form, bound_field, button_layout=None)¶ An Input that lets the user select a
reahl.component.modelinterface.Choice
from a list of valid ones shown as radio buttons of which only one can be selected at a time.Parameters:
TextInput¶
-
class
reahl.web.bootstrap.forms.
TextInput
(form, bound_field, fuzzy=False, placeholder=False)¶ A single line Input for typing plain text.
Parameters: - form – (See
Input
) - bound_field – (See
Input
) - fuzzy – If True, the typed input will be dealt with as “fuzzy input”. Fuzzy input is when a user is allowed to type almost free-form input for structured types of input, such as a date. The assumption is that the bound_field used should be able to parse such “fuzzy input”. If fuzzy=True, the typed value will be changed on the fly to the system’s interpretation of what the user originally typed as soon as the TextInput looses focus.
- placeholder – If given a string, placeholder is displayed in the TextInput if the TextInput is empty in order to provide a hint to the user of what may be entered into the TextInput. If given True instead of a string, the label of the TextInput is used.
- form – (See
PasswordInput¶
PrimitiveCheckboxInput¶
CheckboxInput¶
Button¶
-
reahl.web.bootstrap.forms.
Button
¶ alias of
ButtonInput
ButtonInput¶
ButtonLayout¶
-
class
reahl.web.bootstrap.forms.
ButtonLayout
(style=None, size=None, active=False, wide=False)¶ A ButtonLayout can be used to make something (like an
A
) look like aButton
. It has a few options controlling specifics of that look, and can be used to change the default look of aButton
as well.Parameters: - style – The general style of the button (one of: ‘default’, ‘primary’, ‘success’, ‘info’, ‘warning’, ‘danger’, ‘link’)
- size – The size of the button (one of: ‘xs’, ‘sm’, ‘lg’)
- active – If True, the button is visually altered to indicate it is active (buttons can be said to be active in the same sense that a menu item can be the currently active menu item).
- wide – If True, the button stretches to the entire width of its parent.
Label¶
-
class
reahl.web.bootstrap.forms.
Label
(view, text=None, for_input=None, css_id=None)¶ A label for an Input.
If for_input is given, the Label will only be visible if for_input is visible.
Styling
Rendered as an HTML <label> element.
Parameters: - view – (See
reahl.web.fw.Widget
) - text – If given, used as the text for the label.
- for_input – If given, the
Input
to which this Label applies (its .label is also used as text). - css_id – (See
reahl.web.ui.HTMLElement
)
Changed in version 3.2: Added the for_input keyword argument.
- view – (See
StaticData¶
-
class
reahl.web.bootstrap.forms.
StaticData
(form, bound_field)¶ A fake input which just displays the value of the
Field
to which the StaticData is attached, but does not include a way to change the value.This is useful in cases where you want to display some data that is exposed via a
Field
in a Form amongst normal Inputs.Parameters: