- PHP 8.0
- Symfony >=6.0
- Symfonymailer
Execute the following composer command
composer require alengo/alengo-form-bundle
Enable the bundle by adding it to the list of registered bundles in the config/bundles.php
file of your project:
return [
/* ... */
Alengo\Bundle\AlengoFormBundle\AlengoFormBundle::class => ['all' => true],
];
bin/console do:sch:up --force
Set the following config in your routes_admin.yaml
app_form_data_api:
type: rest
prefix: /admin/api
resource: Alengo\Bundle\AlengoFormBundle\Controller\Admin\FormDataController
name_prefix: app.
Define you default Sender Email in ENV Config.
[email protected]
DEFAULT_SENDER_NAME=Mustermann
You can use and include the following two interfaces to save the forms and send an email with them
public function saveFormDataFromRequest(array $data, string $webspace, string $location, string $category, string $receiverMail = NULL, bool $copy = false): FormData;
public function sendFormDataAsMail(FormData $formData, string $template, string $title, string $receiverMail,string $senderMail,$xmlTemplate = false);
Simple example which sends a copy to the person who filled in the form and his deposited mail
$formData = $this->saveForm->saveFormDataFromRequest($request->request->all(),$request->get('_sulu')->getAttribute('webspace')->getKey(),$request->getLocale(),'contact',NULL,true);
$this->sendForm->sendFormDataAsMail($formData,'hello/email.txt.twig','Welcome Mail','[email protected]');