PHP code example of click66 / psr-forms

1. Go to this page and download the library: Download click66/psr-forms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

click66 / psr-forms example snippets


$factory = new \Click66\Forms\Factory();
$formr = \Click66\Forms\Formr\Adaptr();

$formRenderer = $factory->makeFormRenderer($formr);
$formHandler = $factory->makeFormHandler($formr);

# In your POST route:
$response = $formHandler->process(
    $request,   # PSR-7 RequestInterface
    ['Name(         return new \Click66\Forms\Result\Failure('Something has gone wrong, please try again later.');
        }
    }
)->respond(fn () => response(303)->withHeader('Location', '/form'));    # Return a PSR response. Will run at conclusion of form processing, regardless of outcome.

$captcha = new \Click66\Forms\Captcha\Captcha(
    new \Click66\Forms\Captcha\Credentials(...),
    new \Click66\Forms\Captcha\RecaptchaV2\Verifier(...),   # Currently supports Google ReCaptcha v2.
)
$factory = (new \Click66\Forms\Factory())->withCaptcha($captcha);

# The rest is the same - CAPTCHA will be processed and validated automatically