How to configure à Form?

Hello,

Sorry if my question is very basic, but I don’t understand how to configure fields of au Form.

I try to create au contact form, and I want to add some fiels (name, subject, message, birthdate), but when I creat the form, I don’t see where I can add these fields :

Can you help me ?
Thanks you.

Nicolas.

You can’t do it with the core. Just send any fields and they will be saved.

The mailer only works if you add your mailer settings in config.yaml.

mailer:
    from      : contactform@example.com
    from_name : MyApp
    transport : smtp
    host      : smtphost.provider.com
    user      : fancy-username
    password  : SuperSavePassword
    port      : 587
    auth      : true
    encryption: starttls

If you want form fields, you can build something similar with a collection or use the FormValidation addon.

Ok, I understand how to work Form feature, but, I have another question.

Is it possible to have a dynamic value for email in a form ?

Thanks you.
Nicolas.

Not by default and not with the FormValidation addon (yet).

You could build a custom setup. Leave the mail field empty and add something like this to config/bootstrap.php

$app->on('forms.submit.after', function($form, &$data, $frm){
    // your custom checks...

    try { // catch errror messages from mailer
        // send a custom mail
        $response = $this->app->mailer->mail($sendMyTo, $subject, $body, $options);
    } catch (\Exception $e) {
        $response = $e->getMessage();
    }
    // do something else
});

What is your goal?

Thanks you for this answer. I go to try it.

Bye.
Nicolas.