The two related classes Form and Fb are mostly used for rendering HTML form fields, with Form being the abstracted, user-friendly variant, and Fb being the low-level variant. Many Form methods are derived from the underlying Fb methods of the same name.
For example, the method Fb::text generates the minimal HTML required for the input, like the following:
The corresponding method, Form::text, produces HTML for a label and input, with appropriate classes for CSS styling or JS manipulation, like the following:
<divclass="field-element field-element--text field-element--required"><divclass="field-label"><labelfor="field0">Some field <spanclass="field-label__required">required</span></label></div><divclass="field-input"><inputid="field0"class="textbox"type="text"name="some_field"value=""></div></div>
We recommend that you always use the Form class.
Important methods that you should be aware of are:
Form::loadFromSession, which checks saved session data for form field values and errors associated with form submissions.
Form::nextFieldDetails, which sets a friendly name, mandatory status, and optionally brief explanatory text for the next field to be displayed.
A controller method to display a form should create a view which contains the actual form fields, and could look something like this: