GoodForm


Error Message

Errors can be automatically added to fields by adding a error attribute in the fields attribute array.

errors are used to pass further instructions to the user about a field element.
There are two ways of adding a error to your form object:

error (string message [, string for])

Example:

$this->goodform->error('Username already taken, please choose another.', 'username');

Will produce the following HTML:

<p class="username-error error">Username already taken, please choose another.</p>

error (array attributes)

Example:

$attr = array(
	'for' 	=> 'username',
	'value'	=> 'Username already taken, please choose another.',
	'class'	=> 'my-error-class',
	'title'	=> 'Please correct this error.'
);

$this->goodform->error($attr);

Will produce the following HTML:

<p class="my-error-class username-error error" title="Please correct this error." >Username already taken, please choose another.</p>