qbus / contao-configform-bundle
Define forms using config files instead of the form generator.
Installs: 38
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:contao-bundle
Requires
- php: ^5.6 || ^7.0
- contao/core-bundle: ^4.4.0
- qbus/contao-transient-form: ^1.0.0
This package is auto-updated.
Last update: 2024-12-24 05:22:44 UTC
README
Use config files instead of the form generator to define forms. This makes forms more easily portable.
The forms behave the same way Form Generator forms do because they are rendered, validated and processed by the Contao core. This means, for instance:
- Form hooks, like
compileFormFields
andprepareFormData
, are available; - Form settings like
sendViaEmail
can be used.
Example usage
Create a config file templates/[theme-name/]formconfig_contact.php
:
<?php
return [
'tl_form' => [
'title' => 'Contact',
'sendViaEmail' => true,
'format' => 'email',
'subject' => 'Contact via website form',
'tableless' => true
],
'tl_form_field' => [
[
'type' => 'text',
'name' => 'email',
'label' => 'Email',
'mandatory' => true,
'rgxp' => 'email'
],
[
'type' => 'text',
'name' => 'subject',
'label' => 'Subject',
'mandatory' => true
],
[
'type' => 'textarea',
'name' => 'message',
'label' => 'Message',
'mandatory' => true,
'size' => serialize([8,12])
],
[
'type' => 'submit',
'slabel' => 'Send'
]
]
];
In the Contao backend, create a front end module of the type Form from config file
and select the config.
Use the module wherever the form shall be inserted.