Forms are used to collect user input and configure options of a task the user is completing.
|Included in AUI core?||Yes. You do not need to explicitly require the web resource key.|
|Web resource key:||
|AMD Module key:||N/A|
|Experimental since:||1.0, rewritten in 3.0|
Forms are constructed with a root element (form.aui), containers (commonly for rows), then various input or button types within those containers.
Commonly, there will be a set of fieldsets and field group elements (depending on the input type contained); and in almost all cases a buttons container at the end. Remember all inputs should have a label, it makes them more usable and accessible.
A simple example including a required field:
Note AUI provides the visual style only, you will need to implement validation:
Descriptions go just after their input. They should only be used for non-critical, supplementary text. Critical information must go in the label:
The overall layout of the form can be chosen by adding a class to the root element:
class="aui long-label") - makes the labels wider.
class="aui top-label") – Places labels above form elements (except radios and checkboxes where the label remains to the right of the input). This style is used for forms in narrow spaces.
class="aui unsectioned") – Used for shorter forms that don't require breaking up by section.
You can increase the width of an input (note this is separate from the width of the label, controlled by form layouts) by adding a class to the input:
class="full-width-field"(this will make the field expand to the full available width)
For example, to set a long field: