Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Form Bundle Laravel Package

endroid/form-bundle

Endroid FormBundle lets you build simple forms via Sonata Admin, store submissions, send notification emails when forms are completed, and export results. Extend behavior with custom event listeners.

View on GitHub
Deep Wiki
Context7

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource