All Projects → ansien → RapidFormBundle

ansien / RapidFormBundle

Licence: GPL-3.0 license
Create Symfony forms at record speed using PHP 8 attributes!

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to RapidFormBundle

Rich Model Forms Bundle
Provides additional data mappers that ease the use of the Symfony Form component with rich models.
Stars: ✭ 198 (+500%)
Mutual labels:  symfony-bundle, forms
Liformbundle
Symfony Bundle to render Symfony Forms to JSON Schema
Stars: ✭ 124 (+275.76%)
Mutual labels:  symfony-bundle, forms
stampie-bundle
stampie.github.io/
Stars: ✭ 26 (-21.21%)
Mutual labels:  symfony-bundle
LC-switch
Superlight vanilla javascript plugin improving forms look and functionality
Stars: ✭ 31 (-6.06%)
Mutual labels:  forms
hashed-asset-bundle
Apply an asset version based on a hash of the asset for symfony/asset
Stars: ✭ 24 (-27.27%)
Mutual labels:  symfony-bundle
PRRecaptchaBundle
Recaptcha v3 bundle for Symfony
Stars: ✭ 14 (-57.58%)
Mutual labels:  symfony-bundle
MultipartUploadBundle
Symfony multipart/related/mixed/alternative content type handler (rfc1341).
Stars: ✭ 21 (-36.36%)
Mutual labels:  symfony-bundle
apisearch-bundle
⛵ Apisearch Symfony-Drift Bundle
Stars: ✭ 23 (-30.3%)
Mutual labels:  symfony-bundle
form-saver
A simple script that lets users save and reuse form data.
Stars: ✭ 67 (+103.03%)
Mutual labels:  forms
EasyAdminPlusBundle
EasyAdminPlusBundle is a Symfony 4 wrapper for the amazing EasyCorp/EasyAdminBundle
Stars: ✭ 39 (+18.18%)
Mutual labels:  symfony-bundle
symbok-bundle
Symfony annotations bundle
Stars: ✭ 50 (+51.52%)
Mutual labels:  symfony-bundle
FrontendForms
A module for ProcessWire CMS to create and validate forms on the frontend easily using the Valitron library.
Stars: ✭ 0 (-100%)
Mutual labels:  forms
LiipImagineSerializationBundle
Provides integration between LiipImagineBundle and JMSSerializerBundle
Stars: ✭ 24 (-27.27%)
Mutual labels:  symfony-bundle
connect-bundle
No description or website provided.
Stars: ✭ 35 (+6.06%)
Mutual labels:  symfony-bundle
SonataDoctrineMongoDBAdminBundle
Symfony Sonata / Integrate Doctrine MongoDB ODM into the SonataAdminBundle
Stars: ✭ 64 (+93.94%)
Mutual labels:  symfony-bundle
ng-xform
esss.github.io/ng-xform/home
Stars: ✭ 18 (-45.45%)
Mutual labels:  forms
SonataDashboardBundle
[Abandoned] Provides a Dashboard management through container and block services
Stars: ✭ 17 (-48.48%)
Mutual labels:  symfony-bundle
jsonrpc-bundle
JSON-RPC server for Symfony: exposes services registered in the service container as JSON-RPC-webservices
Stars: ✭ 31 (-6.06%)
Mutual labels:  symfony-bundle
hashids-bundle
Integrates hashids/hashids in a Symfony project
Stars: ✭ 43 (+30.3%)
Mutual labels:  symfony-bundle
ember-validated-form-buffer
A validated form buffer that wraps Ember Data models for use in forms.
Stars: ✭ 46 (+39.39%)
Mutual labels:  forms

RapidFormBundle - Create Symfony forms at record speed using PHP 8 attributes!

Latest Version on Packagist Total Downloads GitHub

Example

The goal of this bundle is to make it possible to build Symfony forms using PHP 8 attributes on your DTO.

The problem

Making forms in Symfony is fairly simple. But once you start using DTO's there will always be two classes you'll have to maintain: your DTO and your Symfony form type. This is not ideal because it creates unnecessary work, maintenance and can also easily lead to bugs.

The solution

This bundle will significantly speed up the creation of forms inside your Symfony application. With the provided PHP 8 attributes you can quickly build forms by decorating your DTO and you won't have to maintain two different classes anymore.

Installation

You can install the package via Composer:

composer require ansien/rapid-form-bundle

Usage

Form

<?php

declare(strict_types=1);

namespace App\Form;

use Ansien\RapidFormBundle\Attribute\Form;
use Ansien\RapidFormBundle\Attribute\FormField;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Validator\Constraints as Assert;

#[Form]
class ExampleForm
{
    #[FormField(TextType::class, [
        'required' => true,
    ])]
    #[Assert\NotBlank]
    public ?string $name = null;

    #[FormField(TextType::class)]
    public ?string $description = null;
}

Controller

<?php

declare(strict_types=1);

namespace App\Controller;

use Ansien\RapidFormBundle\Form\RapidFormBuilderInterface;
use App\Form\ExampleForm;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class ExampleController extends AbstractController
{
    public function __construct(private RapidFormBuilderInterface $formBuilder) 
    {
    }

    #[Route('/example', methods: ['GET', 'POST'])]
    public function __invoke(Request $request): Response
    {
        $data = new ExampleForm();
        $form = $this->formBuilder->create($data)->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            // Do something with $data
        }
        
        return $this->render('example.html.twig', [
            'form' => $form->createView(),
        ]);
    }
}

See ./examples for more examples.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Supporters

Stargazers repo roster for @ansien/RapidFormBundle

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].