Hello all and sorry for bothering you. I am at my very begining with October CMS website developement. I've built a simple contact form taht works great, it validates fields and thow error if they are not ok. My embarassing problem is that I can't show a Success message when the email is sent and the visitors are kinf of confused.
So the contactForm.php file is:
'Contact Form',
'description' => 'Formular contact'
];
}
public function onSend () {
$validator = Validator::make(
[
'name' => input::get('name'),
'phone' => input::get('phone'),
'content' => input::get('content'),
'email' => input::get('email')
],
[
'name' => 'required|min:5',
'phone' => 'required|digits_between:10,30',
'content' => 'required|min:20',
'email' => 'required|email'
]
);
if($validator->fails()) {
//What happens if the validator fails
return Redirect::back()->withErrors($validator);
} else {
// These variables are available inside the message as Twig
$vars = ['name' => input::get('name'), 'email' => input::get('email'), 'company' => input::get('company'), 'phone' => input::get('phone'), 'content' => input::get('content')];
Mail::send('plugin-author.contact::mail.message', $vars, function($message) {
$message->to('the-recipient-email@email.email', 'For');
$message->subject('Subject');
});
}
}
}
The errors are throw out in the components via:
{% for error in errors.all() %}
{{ error }}
{% endfor %}
So here I would like to throw up a "You message has been sent succesfuly" message. Can anyone help me please? The form is submitted via ajax. Thank you in advance. Andrew.
Last updated