inspiredminds/contao-backend-forms

Extension to Contao Haste for quick creation of back end forms.

Maintainers

👁 fritzmg

Package info

github.com/inspiredminds/contao-backend-forms

Forum

Type:contao-bundle

pkg:composer/inspiredminds/contao-backend-forms

Fund package maintenance!

fritzmg

Statistics

Installs: 6 888

Dependents: 3

Suggesters: 0

Stars: 2

Open Issues: 0

1.1.1 2026-03-25 10:45 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

LGPL-3.0-or-later 2393bf5cdf9b29e93db102560ed49a7af2b82291

backendFormscontao


README

👁 Image
👁 Image

Contao Backend Forms

Extension of Codefog\HasteBundle\Form\Form of codefog/contao-haste to quickly build a form for the back end.

Example

Create the form like a regular Haste Form, just via the BackendForm class in your back end controller for example:

// src/Controller/MyFormController.php
namespace App\Controller;

use Contao\CoreBundle\Controller\AbstractBackendController;
use InspiredMinds\ContaoBackendFormsBundle\Form\BackendForm;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

#[Route('%contao.backend.route_prefix%/my-form', name: self::class, defaults: ['_scope' => 'backend'])]
class MyFormController extends AbstractBackendController
{
 public function __invoke(Request $request): Response
 {
 $form = new BackendForm('my-form', 'POST');

 $form->addFormField('lorem', [
 'label' => ['Lorem', 'Lorem description.'],
 'inputType' => 'text',
 'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
 ]);

 $form->addFormField('ipsum', [
 'label' => ['Ipsum', 'Ipsum description.'],
 'inputType' => 'text',
 'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
 ]);

 $form->addSubmitFormField('Submit');

 if ($form->validate()) {
 // Do something …

 return new RedirectResponse($request->getUriForPath($request->getPathInfo()));
 }

 return $this->render('my-form.html.twig', [
 'title' => 'My form',
 'headline' => 'My form',
 'form' => $form,
 ]);
 }
}
{# templates/my-form.html.twig #}
{% extends "@Contao/be_main" %}

{% block main_content %}
 {{ form.generate()|raw }}
{% endblock %}

This would then render a form like this:

👁 Image