Stars: 244
Forks: 38
Pull Requests: 66
Issues: 185
Watchers: 13
Last Updated: 2023-09-13 14:27:52
A versatile Kirby plugin to handle web form actions.
License: MIT License
Languages: PHP
A versatile Kirby plugin to handle web form actions.
This is Uniform for Kirby 3. You can find Uniform for Kirby 2 in the kirby-2 branch.
Builtin actions:
Controller:
<?php
use Uniform\Form;
return function ($kirby) {
$form = new Form([
'email' => [
'rules' => ['required', 'email'],
'message' => 'Email is required',
],
'message' => [],
]);
if ($kirby->request()->is('POST')) {
$form->emailAction([
'to' => '[email protected]',
'from' => '[email protected]',
])->done();
}
return compact('form');
};
Template:
<form action="<?php echo $page->url() ?>" method="POST">
<input name="email" type="email" value="<?php echo $form->old('email'); ?>">
<textarea name="message"><?php echo $form->old('message'); ?></textarea>
<?php echo csrf_field(); ?>
<?php echo honeypot_field(); ?>
<input type="submit" value="Submit">
</form>
<?php if ($form->success()): ?>
Success!
<?php else: ?>
<?php snippet('uniform/errors', ['form' => $form]); ?>
<?php endif; ?>
Install Uniform via Composer: composer require mzur/kirby-uniform
Or download the repository and extract it to site/plugins/uniform
.
Add this to your CSS:
.uniform__potty {
position: absolute;
left: -9999px;
}
Note: Disable the Kirby cache for pages where you use Uniform to make sure the form is generated dynamically.
For the full documentation head over to Read the Docs.
See the answers in the docs, post an issue if you think it is a bug or create a topic in the forum if you need help.
Contributions are always welcome!
Since some people insist on sending me money for this (free) plugin you can do this here.