- Notifications
You must be signed in to change notification settings - Fork39
A versatile Kirby plugin to handle web form actions.
License
mzur/kirby-uniform
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A versatileKirby plugin to handle web form actions.
This is Uniform for Kirby >=3. You can find Uniform for Kirby 2 in thekirby-2 branch.
Builtin actions:
- Email: Send the form data by email.
- EmailSelect: Choose from multiple recipients to send the form data by email.
- Log: Log the form data to a file.
- Login: Log in to the Kirby frontend.
- SessionStore: Store the form in the user's session.
- Upload: Handle file uploads.
- Webhook: Send the form data as an HTTP request to a webhook.
Controller:
<?phpuseUniform\Form;returnfunction ($kirby) {$form =newForm(['email' => ['rules' => ['required','email'],'message' =>'Email is required', ],'message' => [], ]);if ($kirby->request()->is('POST')) {$form->emailAction(['to' =>'me@example.com','from' =>'info@example.com', ])->done(); }returncompact('form');};
Template:
<form action="<?phpecho$page->url()?>" method="POST"> <input name="email" type="email" value="<?phpecho$form->old('email');?>"> <textarea name="message"><?phpecho$form->old('message');?></textarea><?phpechocsrf_field();?><?phpechohoneypot_field();?> <input type="submit" value="Submit"></form><?phpif ($form->success()):?> Success!<?phpelse:?><?phpsnippet('uniform/errors', ['form' =>$form]);?><?phpendif;?>
Install Uniform via Composer:composer require mzur/kirby-uniform
Ordownload the repository and extract it tosite/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 toRead the Docs.
See theanswers in the docs,post an issue if you think it is a bug or create a topic inthe forum if you need help.
Contributions are always welcome!
Since some people insist on sending me money for this (free) plugin you can do thishere.
About
A versatile Kirby plugin to handle web form actions.