The individual elements describing the input portions of the form are arguably the most important part of the form object. They are stored as an associative array in the Solar_Form::$elements property.
Likewise, each element in the
is itself an array describing that element. The descriptor array
The name of the element, to be used as the name attribute for the element in the form.
The type of element, corresponding to a view helper. E.g.,
selectwould use a
formSelecthelper, resulting in an
<select />tag. The
newForm()is able to pick a reasonable type for the element based on the kind of record property; char and varchar columns get
inputtypes, columns that use
selecttypes, booleans get
checkboxtypes, and so on.
A short label to be placed in a <label> tag associated with the element.
A longer piece of narrative text describing the element; this could be used as a tooltip, as help text, or something similar.
The current value of the element.
A boolean indicating if the element is required to be non-blank. The
newForm()method knows that if a table column is
NOT NULL, it should set the element as required.
An array of key-value pairs where the key is the option value, and the value is the option label text. This is used for select and radio types so they know what options to present.
An array of key-value pairs where the key is an XHTML attribute name, and the value is the attribute value.
An array of messages regarding why the element value is invalid (if at all).
Each element corresponds to what its key will be in the
$_POST array (or, if you are using the GET
method, the $_GET array -- generally not recommended but sometimes
necessary). The element names mimic an array format, where the
primary name matches the singular model name, and the keys match
the properties of the model record. However, the names are in fact
a flat list of strings; they just *look* like array keys.
For example, given an
we will see these element names in the form object returned by
<?php $form->elements['blog[title]'] = array(...); // $_POST['blog']['title'] $form->elements['blog[body]'] = array(...); // $_POST['blog']['body'] $form->elements['blog[status]'] = array(...); // $_POST['blog']['status']
These names are also used in the form as the element name.
<input name="blog[title]" ... /> <textarea name="blog[body]">...</textarea> <select name="blog[status]">...</select>