If I successfully submit a form I get: $form->echoMessage()
three times. Which means the text: “Thank you, the form was sent successfully.” is printed out more than once.
That’s strange, because the error messages should not be affected by the message content. If I understand it correctly, message is just the success or failure message, whereas errors should return the error messages. I might be mistaken, though, @mzur?
Almost: message contains the success or error messages (including validation errors) and errors is a list of form field names for which the validation failed.
@Stella Once you pass an argument to the message function it will be restricted to the action, in this case the email action. But the email action does not perform validation, that’s done by Uniform. The (validation) messages of Uniform are stored under the special _uniform key in the messages.
Long story short, do this and you should get back your validation messages:
This works because the email action (0) is only executed if the validation was successful. If not, the message of the email action will be empty and the (validation) message of Uniform is returned instead. You can omit the trim with the newest version of Uniform.