-
Notifications
You must be signed in to change notification settings - Fork 1
Adding form fields
To create a form field, the add_field() method must be called on the form object.
add_field() accepts the following parameters:
- string $field_id - The field ID which will be used for the field's id and name attributes. Alphanumeric characters only.
- string $field_type - One of the valid field types.
- string $label (optional) - The field label to display. Defaults to an empty string.
- array $params (optional) - An array of optional parameters. Defaults to an empty array.
$form->add_field("first_name", "text", "First Name", array(
"placeholder" => "Type your name here"
));HandyMail currently supports the following form field types: text, email, date, select, textarea, radio, checkbox, password
The following optional field parameters are parsed by handymail when supplied within $params:
-
string placeholder: The field placeholder
-
string class: An additional class selector to apply uniquely to this field (appended after any other applied classes).
-
boolean reply_to: If the field type is "email", this parameter governs whether the submitted email is added to the reply-to header. By default it is set to false.
-
string options: A required parameter for select, radio and checkbox form elements. This is where you supply the options to present to the user in string format, with each option delimited with a comma ie: "male,female".
-
int rows: This sets the rows attribute for textarea form elements. Defaults to 10.
-
int fieldset: The fieldset group number the field belongs to. You can read more about this on the Configuring Stylesheets page