Sulu Form Bundle 1.0 release coming soon

Most websites need something like a contact form. The Sulu Form Bundle provides an easy way to create forms in in the admin interface. 

Form fields

In the "Form Fields" section the content manager selects the fields for the form. There are several types available, from simple text fields for "Firstname", "Lastname" to "File Upload" and "Captcha" fields.

Form Fields Configuration Form Fields Configuration

Website Configuration

Form Website Configuration Form Website Configuration

In the "Website configuration" section the content manager can add the text which should be displayed after a form is successfully submitted.

E-Mail Configuration

In the "E-Mail Configuration" section the content manager selects the E-Mail addresses that will be notified when a form was successfully submitted and sets if an attachment should be added to the mail. 

Form Email Configuraiton Form Email Configuraiton

Creating the theme

To render a form on the website developers can create custom themes. The symfony form theming component allow to create reusable field blocks for easy styling. 

Basically, you just need to extend from the default dynamic theme and overwrite the blocks from the existing theme. The following example will show you how to remove the label and use the label as a placeholder.

{% extends 'SuluFormBundle:themes:dynamic.html.twig' %}

{%- block form_row -%}
    {{ block('sulu_form_row_start') }}
    {{- form_label(form, label|default, { 'label_attr': {'class': 'sr-only'} }) }}
    {{- form_errors(form) -}}
    {{- form_widget(form) -}}
    {{ block('sulu_form_row_end') }}
{%- endblock -%}

{% block attributes -%}
    {% set attr = attr|merge({placeholder: label}) %}
    {{ parent() }}
{%- endblock attributes -%}

Export data

The Sulu form bundle also provides a view of all submitted data inside the "Data" tab of the form. This data can be exported as CSV so you can easy make statistics out of this data.

When using the form bundle?

The Sulu form bundle is built for relatively simple applications like e.g. a contact form. When you need no relation to other entities, want to export the data as CSV and getting notifications by E-Mail, the form bundle is the right choice for you. If you need to create forms where data needs to be saved into a specific entities you should build a custom controller. The form bundle will reach 1.0 soon give us feedback on github if you have any issues with it.