GithubHelp home page GithubHelp logo

pedroborges / kirby-uniform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mzur/kirby-uniform

1.0 2.0 0.0 409 KB

A versatile Kirby plugin to handle web form actions.

Home Page: https://kirby-uniform.readthedocs.io

License: GNU General Public License v2.0

PHP 100.00%

kirby-uniform's Introduction

Kirby Uniform

A versatile Kirby plugin to handle web form actions.

Documentation Status Build Status saythanks

This is Uniform for Kirby 3. You can find Uniform for Kirby 2 in the kirby-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.

Quick example

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]',
      ]);
   }

   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; ?>

Installation

composer require mzur/kirby-uniform:^4.0

You can also download the repository and extract it to site/plugins/uniform.

Setup

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.

Documentation

For the full documentation head over to Read the Docs.

Questions

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 (be sure to mention @mzur).

Contributing

Contributions are always welcome!

Donations

Since some people insist on sending me money for this (free) plugin you can do this here. You can also say thank you.

kirby-uniform's People

Contributors

alkinkasap avatar creichel avatar davidelanfranchi avatar dpschen avatar flixt avatar getu-lar avatar julien-gargot avatar ldanielswakman avatar lord-executor avatar macxim avatar maxxst avatar mzur avatar rhawbert avatar seb-celinedesign avatar webcatsolutions avatar yoanmalie avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.