Text, Mail, URL, Tel, Password

Add Field

Text, E-Mail, URL, Password

// Text field example
$form->addField('Your Name', 'text', array('placeholder' => 'Please enter your name',
															         'maxlength'   => 35
                                    ));

// E-Mail field example
$form->addField('Your E-Mail', 'email');

URL

// URL field examples
$form->addField('Your Website', 'url');
$form->addField('Your Website', 'url', ['strict' => false]);

URL fields support an additional parameter strict which is true by default. Strict validation only allows URL's with a hyper text protocol prefix such as http://

Tel (phone)

// Tel field example
$form->addField('Your Mobile', 'tel');

Phone fields only accept numeric characters as well as + - / and spaces. Furthermore, maxlength is set to 20 by default. Please use regex to validate country specific phone number formats.

Password

// Passowrd field example
$form->addField('Your Password', 'password', array(
	'placeholder' => 'Plase define a Password',
	'regex' => '/^(?=.*[A-Z])(?=.*[!@#$&*])(?=.*[0-9])(?=.*[a-z]).{8,16}$/'
));

/*
 Passord complexity rules might be granted with regular expressions.

 The example regex ensures:
 - password contains at least 1 number
 - password contains at least 1 uppercase letter
 - password contains at least 1 lowercase letter
 - password contains at least 1 non-alpha numeric number
 - password is 8-16 characters long
*/

Attributes

You can customize the field with one of these optional parameters:

Parameter Type Default Info
required boolean true Validation will return false when the field is left empty
classlist string has-error will be added to classes if validation returns false.
is-valid will be added if the validation was successful.
Add classes to input field and its field wrap e.g. column-with classes of a grid system.
label string Label for input field
placeholder string Input field placeholder
regex String Validation will match input against this regular expression
maxlength int Maximum number of input characters
readonly string false Read-Only field if it only is available under specific circumstances.
autofocus string false Set cursor autofocus to this field. Only use for a single field per form.
strict boolean true URL fields only! Strict validation only allows URL's with a hyper text protocol prefix such as http://