Deprecation note (06/2022): This module has been deprecated in favour of a new RockForms module that does not only use NetteForms but also comes with a GUI. You can still use this module if you want, but I will not provide any fixes or updates or support!
https://gitlab.com/baumrock/RockForms
It uses the great NetteForms from Nette Framework (docs: https://doc.nette.org/en/2.4/forms )
Features:
Client AND Server-side validation in one go (you only need to code your rules ONCE)
CSRF protection (by processwire)
Honepot spam protection (custom)
Helper to create PW pages from submitted forms ($form->createPage($parent, $template, $title))
Add ?success=yourform tag to url ONLY after successful submission (for analytics)
Recover fields after unsuccessful submission (server side validation error)
Define custom actions + message on successful submission
UiKit form renderer (more can be accepted by pull requests)
Sample Form Setup:
<?php namespace ProcessWire;
$form = $modules->get('RockForms')->form;
$form->addRadioList('salut', 'Anrede', ['m' => ' Herr', 'w' => ' Frau']);
$form->addText('forename', 'Vorname');
$form->addText('surname', 'Nachname');
$form->addText('email', 'E-Mail-Adresse')
->setRequired('Bitte geben Sie Ihre Mailadresse an')
->addRule(Form::EMAIL)
;
$form->addSubmit('submit', 'Anfrage senden');
$form->onSuccess = function($form) {
$form->createPage(1017, 'mailitem', date('d.m.Y H:i:s') . ', {forename} {surname} {email}');
// send email
// do whatever you want
// return success message
return 'thank you for your subscription';
};
echo $form->render();
For all available fields you can look here: https://doc.nette.org/en/2.4/form-fields
Validation: https://doc.nette.org/en/2.4/form-validation
Rendering: https://doc.nette.org/en/2.4/form-rendering
More complex form example of the screencast:
Module is alpha and not well tested yet. It should be save to use, but there might be breaking changes in the future. Also I'm quite sure that not all possible situations are covered. There are some switch() statements that check for the fieldtype and I only implemented the ones I needed so far. All others are easy to add - please make pull requests if you find any unsupported fields. Thank you.
LIMITATIONS:
Multiform support limited
Changelog:
6.8.18 add multiform support
8.4.18 v2 little bugfix + load assets automatically
19.3.18 alpha release