create a new form
$form = new Zebra_Form('my_form');
add a text control to the form
$obj = $form->add('text', 'my_text');
make the text field required
$obj->set_rule(
'required' => array(
'error', // variable to add the error message to
'Field is required' // error message if value doesn't validate
)
);
don't forget to always call this method before rendering the form
if ($form->validate()) {
put code here
}
output the form using an automatically generated template
$form->render();
public add ( string $type ) : reference | ||
$type | string | Type of the control to add. Controls that can be added to a form: - {@link Zebra_Form_Button buttons} - {@link Zebra_Form_Captcha CAPTCHAs} - {@link Zebra_Form_Checkbox checkboxes} - {@link Zebra_Form_Date date pickers} - {@link Zebra_Form_File file upload controls} - {@link Zebra_Form_Hidden hidden controls} - {@link Zebra_Form_Image image button controls} - {@link Zebra_Form_Label labels} - {@link Zebra_Form_Note notes} - {@link Zebra_Form_Password password controls} - {@link Zebra_Form_Radio radio buttons} - {@link Zebra_Form_Reset reset buttons} - {@link Zebra_Form_Select selects} - {@link Zebra_Form_Submit submit buttons} - {@link Zebra_Form_Text text box controls} - {@link Zebra_Form_Textarea textareas} - {@link Zebra_Form_Time time pickers} @param mixed $arguments A list of arguments as required by the control that is added. @return reference Returns a reference to the newly created object |
return | reference |