How to store Contact form data in Database in PyroCMS 3.x

67 Views Asked by At

How do I store the data in the Database for a website using pyrocms.

I currently use the contact plugin and need to store the data in mysql.

If anyone has done this, I would appreciate the help!

1

There are 1 best solutions below

1
Ryan Thompson On BEST ANSWER

The contact plugin does not capture data, but you can indeed save the input by slightly extending it.

You will need to have a table made to put it in. Otherwise, you could make a Stream to stuff the data into as well.

The easiest way is likely to use the posted callback on the ContactFormBuilder.

Something like this:

use \Anomaly\ContactPlugin\Form\ContactFormBuilder;

app(ContactFormBuilder::class)->listen('posted', function(ContactFormBuilder $builder) {
    YourStreamModel::create($builder->getFormInput());
}