Archive
SilverStripe Forums » Archive » Translating Validation Form Error Messages
Our old forums are still available as a read-only archive.
|
Page:
1
|
Go to End | |
| Author | Topic: Translating Validation Form Error Messages | 2051 Views |
-
Translating Validation Form Error Messages

24 June 2008 at 7:38pm Last edited: 24 June 2008 7:38pm
Hey there everyone,
I'm trying to build my first Silverstripe site and I'm quite content with it, yet I have stumbled upon a problem that I was not able to solve yet.
I've created a contact form and drag-and-dropped all fields that I want, and it works like a charm, with a tiny problem: If the user focuses, say, an email field and then focuses another (or submits the form without filling in his email), I get the message:
"Please fill in Deine Email-Adresse, it is required"
Not something that will get my customer happy, I'm afraid.
I took a short glimpse, and this error message seems to be hard coded into the sapphire core.Anyone got an idea of how to change this without hacking away at the core code or setting up my own contact form?
Regards,
Jörn -
Re: Translating Validation Form Error Messages

28 June 2008 at 6:26pm
form validation is being improved for the 2.3 release, which is unfortunately still a while away.
one of the bulletpoints here is to make localization easier in both client- and serverside.
you might want to have a look at our development plan: http://open.silverstripe.com/wiki/development/validationfor now, you'd have to overload the javascript in Validator.js and subclass RequiredFields.php.
-
Re: Translating Validation Form Error Messages

1 July 2008 at 11:46pm
Works like a charm, although it's a bad hack, thank you lots!
Looking forward to the next release, then!
-
Re: Translating Validation Form Error Messages

19 July 2008 at 8:31pm
hi
if 2.3 form translation feature is a while away,
can anyone post a sample of how to translate validation messages properly for forms
-
Re: Translating Validation Form Error Messages

22 July 2008 at 11:20pm
(in your controller php code):
Requirements::customScript("Behaviour.register({'#MyForm': { initialise: function() { this.requiredErrorMsg = 'Bitte füllen Sie das Feld $FieldLabel aus';}});no guarantee on right bracketing, just wrote it down... $FieldLabel is automatically replaced in javascript. Have a look through Validator.js, you can customize this on a field-by-field level as well. Having custom validation messages e.g. for EmailField gets a bit trickier, the easiest way is to subclass the FormField instance.
Its a pain in the ass, we're working on it ;)
-
Re: Translating Validation Form Error Messages

23 July 2008 at 3:52pm
Nice method. more simple than extending UserDefinedForm, sample here
http://www.webmasterbulletin.net/2008/07/silverstripe-form-validation-translation/78
| 2051 Views | ||
|
Page:
1
|
Go to Top |


