Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.
/ form-bundle Public archive

Form Generation Bundle for use in Symfony

License

Notifications You must be signed in to change notification settings

abandroid/form-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Form Bundle

By endroid

Latest Stable Version Build Status Total Downloads Monthly Downloads License

The Endroid FormBundle enables users to create basic forms through the Sonata Admin Bundle. It includes form configuration, storage of results, sending of notifications when a form is filled in and even the possibility to export form results.

knpbundles.com

Requirements

  • Symfony

Installation

Use Composer to install the bundle.

$ composer require endroid/form-bundle

Then enable the bundle via the kernel.

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new Endroid\FormBundle\EndroidFormBundle(),
    ];
}

Usage

Forms are created via Sonata Admin and can be rendered directly in your template as follows.

{{ render(controller('EndroidFormBundle:Form:show', { form: form })) }}

When a form is filled in correctly a result is generated and a form success event is dispatched. You can specify via Sonata Admin whether this result should be stored and if a confirmation email should be sent.

Extension

Event listeners

Event listeners exist for storing the result and sending a confirmation mail (depending on your settings). You can extend this functionality by adding your own listener or by overriding any of the existing.

/**
 * {@inheritdoc}
 */
public static function getSubscribedEvents()
{
    return [FormSuccessEvent::NAME => 'myHandler'];
}

/**
 * My custom form success handler.
 *
 * @param FormSuccessEvent $event
 */
public function myHandler(FormSuccessEvent $event)
{
    $result = $event->getResult();
    $form = $result->getForm();

    //...
}

And register it via the service container.

acme.event_listener.my_listener:
    class: Acme\EventListener\MyListener
    tags:
        - { name: kernel.event_subscriber }

Fields

New fields can be added by extending the Field class, creating a service definition for the the new field and adding the tag "endroid_form.field".

acme.field.my_field:
    class: Acme\Entity\MyField
    tags:
        - { name: endroid_form.field }

Versioning

Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.

License

This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.

About

Form Generation Bundle for use in Symfony

Resources

License

Stars

Watchers

Forks

Packages

No packages published