Till now the rendering of forms has all been handled by the default rendering method. From a prototype point of view, this method has allowed us to create a nice, clean form. The only problem we now face is that there are situations where this rendering is not flexible enough.
To render the form, we have been echoing the $form
object in the template. This, in fact, is a shortcut to $form->render()
. However, there are several rendering functions available for use. We will be using these to customize our form on the template further. To demonstrate this, I will apply these functions to the email field before presenting to you the final version.
The email section of the form can be broken up into three areas: the label, the form field, and the error message. We are going to use three of the rendering functions to completely customize the email section:
Setting a label: For setting the label, we can use the
$form['email']->renderLabel()
function....