PHP code example of hostnet / form-handler-bundle

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

    

hostnet / form-handler-bundle example snippets


class YourController extends Controller
{
    public function formAction(Request $request, MyEntityUser $user)
    {
        $handler = $this->get('hostnet.form_handler.factory')->create(MyFormHandler::class);

        if (($response = $handler->handle($request, new MyFormData())) instanceof RedirectResponse) {
            return $response;
        }

        // regular or in-valid flow
        return $this->render->renderView('/your/form.html.twig', [
            'form' => $handler->getForm()->createView()
        ]);
    }
}