Hallo,
Voor een kennis ben ik een simpele site aan het bouwen in combinatie met October CMS. Verder werkt alles prima, behalve het contactformulier..
Nu heb ik zelf een custom plugin gebouwd met behulp van deze YouTube tutorial. Het formulier wordt doormiddel van een AJAX post request naar de OnSend functie gestuurd, tenminste dat is bedoeling, maar hij post het formulier naar contact.php. Terwijl die dus helemaal niet bestaat.
De code:
Plugin.php:
/components map Contactform.php
Formulier zelf:
Iemand die hier ervaring mee heeft en me op weg kan helpen?
Alvast bedankt.
Voor een kennis ben ik een simpele site aan het bouwen in combinatie met October CMS. Verder werkt alles prima, behalve het contactformulier..
Nu heb ik zelf een custom plugin gebouwd met behulp van deze YouTube tutorial. Het formulier wordt doormiddel van een AJAX post request naar de OnSend functie gestuurd, tenminste dat is bedoeling, maar hij post het formulier naar contact.php. Terwijl die dus helemaal niet bestaat.
De code:
Plugin.php:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| <?php namespace RvB\Contactform; use System\Classes\PluginBase; class Plugin extends PluginBase { public function registerComponents() { return [ 'RvB\ContactForm\Components\ContactForm' => 'contactform', ]; } public function registerSettings() { } } |
/components map Contactform.php
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| <?php namespace RvB\ContactForm\Components; use Cms\Classes\ComponentBase; use Input; use Mail; /** * */ class ContactForm extends ComponentBase { public function componentDetails() { return [ 'name' => 'Contact Form', 'description' => 'Simple contact form' ]; } public function onSend() { $vars = ['name' => Input::get('name'), 'email' => Input::get('email'), 'company' => Input::get('company'), 'phone' => Input::get('phone'), 'message' => Input::get('comment')]; Mail::send('rvb.contactform::mail.message', $vars, function($message) { $message->to('info@info.nl'); $message->subject('Aanvraag via de website'); }); } } ?> |
Formulier zelf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| <form id="contact-form" data-request="{{__SELF__}}::onSend"> <p>Naam * <br> <span class="wpcf7-form-control-wrap your-name"> <input name="name" id="name" type="text" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></span> </p> <p>Bedrijf <br> <span class="wpcf7-form-control-wrap your-name"> <input name="company" id="company" type="text" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></span> </p> <p>E-mail * <br> <span class="wpcf7-form-control-wrap your-email"> <input name="email" id="email" type="text" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" aria-invalid="false"></span> </p> <p>Telefoonnummer <br> <span class="wpcf7-form-control-wrap your-subject"> <input name="phone" id="phone" type="text" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" aria-invalid="false"></span> </p> <p>Bericht * <br> <span class="wpcf7-form-control-wrap your-message"> <textarea name="comment" id="comment" cols="40" rows="10" class="wpcf7-form-control wpcf7-textarea" aria-invalid="false"></textarea></span> </p> <p> <input type="submit" value="Versturen" id="submit_contact"> </p> </form> |
Iemand die hier ervaring mee heeft en me op weg kan helpen?
Alvast bedankt.
DJI Mavic 3 Classic | i7-8700 - GTX1070Ti - 16GB RAM