PHP code example of piwi91 / form-handler

1. Go to this page and download the library: Download piwi91/form-handler 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/ */

    

piwi91 / form-handler example snippets


public function anActionInAController(Request $request)
{
    $formHandler = new MyFancyFormHandler($formFactory, $form);

    $form = $formHandler->form();

    if ($request->isMethod('POST') {
        try {
            $formHandler->process($form, $request);
        } catch (ValidationException $e) {
            // Do something with the validation... or not ;-) (and render the page including the validation errors)
        }
    }

    return $this->render('my_view.html.twig', ['form' => $form->createView()]);
}