1

I get these standard error messages instead of my custom ones

The comments field is required.

The name field is required. The email

must be a valid email address.


Even though in the component I have these settings:

[genericForm contactForm]
group = "Contact"
rules[comments] = "required"
rules[name] = "required"
rules[email] = "required|email"
rules[phone] = "numeric"
rules_messages[name.required] = "Gelieve uw naam in te vullen"
rules_messages[comments.required] = "U bent uw vraag vergeten te stellen"
rules_messages[email.required] = "Gelieve uw email toe te voegen"
rules_messages[email.email] = "Uw e-mail adres klopt niet"
rules_messages[phone.numeric] = "Uw telefoonnummer klopt niet"
messages_success = "Uw formulier was succesvol verzonden. We nemen zo spoedig mogelijk contact met u op!"
messages_errors = "Er zijn problemen met het versturen van het formulier"
mail_enabled = 1
mail_recipients[] = "miguel@kixx-concept.be"
reset_form = 1
inline_errors = "display"
sanitize_data = "disabled"
anonymize_ip = "disabled"
recaptcha_theme = "light"
recaptcha_type = "image"
recaptcha_size = "normal"

Both the flash messages are displaying correctly though, it's just the custom messages. It's pretty clear in the docs on how you should it, so what am I missing here?

Extra question: I've been able to make it work with 'inline errors: display errors'. But I haven't found how I can get that flash error message to appear on top on invalid submit while having chosen inline errors.

Empi
  • 94
  • 1
  • 9

1 Answers1

0

What do you mean by "Both the flash messages are displaying...?"

If you aren't getting the default flash message appearing on your page, make sure you have jquery and framework extras loaded.

Here is how I have the component setting up and it works fine. This is when looking at the page file in the themes folder.

[genericForm]
rules[name] = "required"
rules[email] = "required|email"
rules_messages[name.required] = "We need your Name please"
rules_messages[email.email] = "Your Email needs have a correct syntax"
rules_messages[email.required] = "We need your Email please"
messages_success = "Your form was successfully submitted"
messages_errors = "There were errors with your submission"
inline_errors = "disabled"
sanitize_data = "disabled"
anonymize_ip = "disabled"
recaptcha_theme = "light"
recaptcha_type = "image"
recaptcha_size = "normal"

enter image description here

enter image description here

enter image description here

Pettis Brandon
  • 875
  • 1
  • 6
  • 8
  • Thanks for your reply. Both the flash messages show the input text that I have set, so that's good. Its the other messages like name.required that shows the default message ('The name field is required'). I have updated my question with the raw component code, as you can see there is nothing wrong with it. – Empi Mar 05 '19 at 16:22
  • @empi Are you using {% component 'genericForm' %} or your own twig code? – Pettis Brandon Mar 05 '19 at 18:10
  • I have a CMS page contact.htm wherein I call {% component 'contactForm' %}. That's what the docs are saying I should do. I've tried several things: take the component code and put it right into contact.htm (had to change `__SELF__` to contactForm). Took the default code and placed it into the partial or straight into contact.htm, all yielded the same results. – Empi Mar 06 '19 at 08:22