Each form field in Nibble forms has a PHP method that allows a custom error message to be set that overrides the default messages. This can be useful if one form requires a different message to the rest of the forms on the site. (If all of the forms on the site require a different message to the default ones it would be quicker to change the values in the PHP classes themselves). For example, an email form is invalid if it is empty (depending on the required argument being True) or the value submitted is not a valid email address. Knowing this means a generic polite error message that covers both instances could be set:
1 2 3 4 |
// Instantiate the field $form->email = new Email(‘Please enter your email’); // Add the custom error message $form->email->errorMessage(“Excuse me, the value you entered into the email field was not a valid email address, please rectify this issue”); |
Luke Rotherfield
Freelance PHP Developer
is a PHP developer dedicated to writing the most awesome liraries for his fellow devs :) enjoy