Form
The form is the base element of data entry within Winter CMS. A form is made up of controls, which can be input fields or widgets. In general, the form is generally created by the Form Widget, but can also be manually created for custom uses.
The basics
A form should be made up of a <form>
tag. Each individual input or control within the form should be surrounded by a <div class="form-group">
container, similar to the Bootstrap v4 format.
Within each form group, there should be a <label>
tag for the field label, and a control or input that has the class form-control
to identify the actual interactive element. For usability, you should endeavour to include a for
attribute on the label that matches the name
attribute of the field that label is for.
Alignment
Form fields can be spanned on either the left or right half of the page, or across the entire page, providing a simple way of organising fields. Simply add the span-left
class to the form-group
container for a field you wish to align to the left half of the form, span-right
for the right half, or span-full
(or no class) to span the entire width of the form.
For more flexible control of the design of the form, you can also use Bootstrap's Grid system to control the width of the form fields.
NOTE: The Winter CMS Backend uses the Bootstrap v3 Grid system.
Required fields
Adding the class is-required
to the form-group
container of a field visually indicates to the user that this field is required. Note that this does not "force" the field to be entered - instead, you must enforce this via client-side or server-side validation.
Disabled and read-only fields
Adding a disabled
or readonly
attribute to the input (form-contol
) will make the field either disabled or read-only. A disabled field cannot be interacted with at all, and will not be submitted with the form. A read-only field will be submitted with the form, but cannot be modified.
Complete example
The following is a complete example of a form, including all field types.