Giter Site home page Giter Site logo

anselmh / kirby-uniform-turnstile Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 0.0 12 KB

A Kirby 3 plugin implementing a Cloudflare Turnstile guard for the Uniform plugin.

License: MIT License

PHP 100.00%
kirby-3 kirby-cms kirby-plugin kirby-plugins kirby3 kirby3-plugin

kirby-uniform-turnstile's People

Contributors

anselmh avatar bvdputte avatar lukasleitsch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kirby-uniform-turnstile's Issues

Class "Uniform\Guards\Guard" not found

I am getting the error 'Class "Uniform\Guards\Guard" not found'

Line 8 of src/Guards/TurnstileGuard.php:

class TurnstileGuard extends Guard

Manual install to remote server running php 8.0.28

Undefined function

Have followed instructions but get 'Call to undefined function turnstileField()'.

Plugin installed in plugins/kirby-uniform-turnstile

Template:

`

<div class="row">

  <?php if ($form->success()): ?>
  <div class="col-lg-12 alert alert-success">
    Thank you for your message. A member of our team will be in touch shortly to discuss your enquiry.
  </div>
  <?php else: ?>
  <div class="col-lg-12">
    <?php snippet('uniform/errors', ['form' => $form]) ?>
  </div>
  <?php endif; ?>
  
  <div class="form-group col-lg-4">
    <label>First Name</label>
    <input<?php if ($form->error('firstName')): ?> class="error" <?php endif; ?> name="firstName" type="text"
      value="<?php echo $form->old('firstName') ?>" required>
  </div>

  <div class="form-group col-lg-4">
    <label>Last Name</label>
    <input<?php if ($form->error('lastName')): ?> class="error" <?php endif; ?> name="lastName" type="text"
      value="<?php echo $form->old('lastName') ?>" required>
  </div>

  <div class="form-group col-lg-4">
    <label>Company</label>
    <input<?php if ($form->error('company')): ?> class="error" <?php endif; ?> name="company" type="text"
      value="<?php echo $form->old('company') ?>" required>
  </div>

  <div class="form-group col-lg-4">
    <label>Post Code</label>
    <input<?php if ($form->error('postCode')): ?> class="error" <?php endif; ?> name="postCode" type="text"
      value="<?php echo $form->old('postCode') ?>" required>
  </div>

  <div class="form-group col-lg-4">
    <label>Email Address</label>
    <input name="customerEmail" type="email" value="<?php echo $form->old('customerEmail') ?>" required>
  </div>

  <div class="form-group col-lg-4">
    <label>Phone Number</label>
    <input<?php if ($form->error('phone')): ?> class="error" <?php endif; ?> name="phone" type="telephone"
      value="<?php echo $form->old('phone') ?>" required>
  </div>

  <div class="form-group col-lg-12">
    <label>Message</label>
    <textarea<?php if ($form->error('message')): ?> class="error" <?php endif; ?> name="message" rows="7"><?php echo $form->old('message') ?></textarea>
  </div>

  <?php echo csrf_field() ?>
  <?= turnstileField() ?>

  <div class="form-group col-lg-12 font-serif fw-300 py-3">
    All fields required. We do not share your data with 3rd parties. <a href="<?= $site->url()?>/privacy-policy" title="privacy policy">Privacy Policy</a>.
  </div>
  

  <div class="form-group col-lg-12">
    <input type="submit" value="Send" id="submit-btn" class="button dark rbl-bg-primary chevron">
  </div>

</div>
`

Controller:

`<?php

use Uniform\Form;

return function ($kirby)
{
$form = new Form([
'firstName' => [],
'lastName' => [],
'customerEmail' => [],
'postCode' => [],
'phone' => [],
'company' => [],
'message' => [
'rules' => ['required'],
'message' => 'Please enter a message',
],
]);

if ($kirby->request()->is('POST')) {
    $form->turnstileGuard()
        ->emailAction([
        'to' => '[email protected]',
        'from' => '[email protected]',
        'subject' => 'Web Enquiry',
        'template' => 'web-form',
    ]);
}

if (r::is('POST')) {
    $form->logAction([
        'file' => kirby()->roots()->site().'/messages.log',
    ]);
}

return compact('form');

};`

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.