Simple handling from Symfony Forms in Sulu.io.
You can use this Bundle to create and handle dynamic forms.
This Bundle will allow the content manager to create custom forms
in the backend which can selected with a content type to be displayed at a specific page.
Also this Bundle handles the problem with the CSRF Token
and HTTP Cache
.
A simple Controller is provided to handle a Symfony Form with CSRF Token.
The mail
dispatching is handled by the bundle.
Run the following command to install:
composer require sulu/form-bundle
Enable the required bundles in the config/bundles.php
of your project:
Sulu\Bundle\FormBundle\SuluFormBundle::class => ['all' => true],
Activate esi for csrf token reload on cache pages
by change the following lines in config/packages/framework.yaml
.
framework:
esi: true
fragments: true
Configure the default sender and receivers email address (optional):
sulu_form:
mail:
from: "%env(SULU_ADMIN_EMAIL)%"
to: "%env(SULU_ADMIN_EMAIL)%"
sender: "%env(SULU_ADMIN_EMAIL)%"
Optional configure the email handler to SwiftMailer (swift_mailer
) or the Symfony Mailer (mailer
):
sulu_form:
mail:
helper: "swift_mailer" # is default
Execute the following command to get the sqls to update your database.
php bin/adminconsole doctrine:schema:update --dump-sql
You can use --force
to run the sqls but be carefully which other
sql statements are executed. Its recommended to use DoctrineMigrationsBundle
to update production databases.
Add the following lines to config/routes/sulu_admin.yaml
sulu_form_api:
type: rest
resource: "@SuluFormBundle/Resources/config/routing_api.yml"
prefix: /admin/api
Make sure you've set the correct permissions in the Sulu backend for this bundle!
- Dynamic Forms
- Static Forms (deprecated)
Using varnish have a look at the CSRF documentation.