|
Custom Message Types
FormBuilder supports the following message types, which are
set using the messages option:
| Message |
Default |
| js_invalid_start |
'%s error(s) were encountered with your submission:' |
| js_invalid_end |
'Please correct these fields and try again.' |
| js_invalid_input |
'- You must enter a valid value for the "%s" field' |
| js_invalid_select |
'- You must choose an option for the "%s" field' |
| js_invalid_checkbox |
'- You must choose an option for the "%s" field' |
| js_invalid_radio |
'- You must choose an option for the "%s" field' |
| js_invalid_password |
'- You must enter a valid value for the "%s" field' |
| js_invalid_textarea |
'- You must fill in the "%s" field' |
| js_invalid_file |
'- You must specify a valid file for the "%s" field' |
| form_required_text |
'<p>Fields shown in <b>bold</b> are required.' |
| form_invalid_text |
'<p>%s error(s) were encountered with your submission. Please correct the fields <font color="%s"><b>highlighted</b></font> below.' |
| form_invalid_color |
'red' |
| form_invalid_input |
'You must enter a valid value' |
| form_invalid_select |
'You must choose an option from this list' |
| form_invalid_checkbox |
'You must choose an option from this group' |
| form_invalid_radio |
'You must choose an option from this group' |
| form_invalid_password |
'You must enter a valid value' |
| form_invalid_textarea |
'You must fill in this field' |
| form_invalid_file |
'You must specify a valid filename' |
| form_select_default |
'-select-' |
| form_submit_default |
'Submit' |
| form_reset_default |
'Reset' |
| form_confirm_text |
'Success! Your submission has been received %s.' |
Any instance of "%s" is filled in with the appropriate value.
To override any of the defaults, simply specify the appropriate
message type to the messages option:
$form = CGI::FormBuilder->new(
fields => \@fields,
messages => {
form_select_default => '--',
form_invalid_password => 'Make sure your password uses numbers and letters',
}
);
|
Alternatively, you can specify a filename to the messages
option, which allows you to defined a common set of messages and
reuse them in all your scripts. For more information, see
this tutorial.
You can use any string you want for the message, including
text in other languages. This allows you to fully customize
the interface for your native language.
|