piwi91/FormHandler


A Form Handler implementation

License: MIT

Language: PHP


FormHandler

Build Status

This is a Form Handler implementation which I used in combination with the Symfony Form component.

Click here to go to the blog post I wrote about the form handler.

Usage

Implement the FormHandlerInterface OR extend the AbstractFormHandler and implement the postProcess method.

You can use a try/catch to catch validation exceptions.

Example:

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

Project Statistics

Sourcerank 2
Repository Size 149 KB
Stars 0
Forks 1
Watchers 2
Open issues 0
Dependencies 4
Contributors 2
Tags 1
Created
Last updated
Last pushed

Top Contributors See all

Dennis de Greef Pim Widdershoven

Packages Referencing this Repo

piwi91/form-handler
A Form Handler implementation for the Symfony Form Component
Latest release v1.0.0 - Published

Recent Tags See all

v1.0.0 September 18, 2015

Something wrong with this page? Make a suggestion

Last synced: 2016-05-27 18:38:55 UTC

Login to resync this repository