So, I managed to modify texts and translations from within my controller, and thus avoiding to mess up with Sapphire.
It's not an elegant solution but it works.
There are 2 issues :
- It's not possible to set a specific required-validation text for each field. A global "%s is required" is the only option I'm aware of.
- For the Javascript required-validations, you have to target the field by their Html IDs. Those IDs can change if you modify the form in the CMS.
class ContactPage_Controller extends UserDefinedForm_Controller {
public function init() {
parent::init();
global $lang;
// Php and Javascript formating-validations for email fields
$lang['en_US']['EmailField']['VALIDATION'] = $lang['en_US']['EmailField']['VALIDATIONJS'] = 'It seams your email address is not really valid.';
// Php required-validations
$lang['en_US']['Form']['FIELDISREQUIRED'] = 'Could you please fill the field %s because it\'s important to us';
// Javascript required-validations for each field
Requirements::customScript( "
if( typeof Behaviour != 'undefined') {
Behaviour.register({
'#Form_Form_EditableTextField2' : { requiredErrorMsg: 'Knowing who you are is important to us. Please give us a name, and your company\'s one too, if applicable.' },
'#Form_Form_EditableEmailField4' : { requiredErrorMsg: 'Please give us your email address, or we sadly won\'t be able ton get in touch with you.' }
}); // register()
} // if != undefined
"); // customScript()
} // init()
} // ContactPage_Controller