Back to Form Builder Support

tiendo1527471
tiendo1527471

Hi,

I want use this plugin to make a form to front end. When visitor press submit, data of form will update to table (ex: Product table). How i do this?

Thank you so much!

Renatio
Renatio

Hi,

in the future plugin will support this, but not now.

You can create custom plugin and extend FormBuilder plugin. In custom plugin Plugin.php boot() method paste something like this:

Event::listen('formBuilder.beforeSendMessage', function ($form, $data) {
    DB::table('products')->insert(
        ['name' => $data['name']
    );

    return true; // this will prevent sending email message
});

If you have Product model you can use it instead of Query Builder . You will have to know a little Laravel to do all of this.

Let me know if you want more help.

Last updated

tiendo1527471
tiendo1527471

Hi, Thank you so much, :)!

Codebugs
Codebugs

Renatio said:

Hi,

in the future plugin will support this, but not now.

You can create custom plugin and extend FormBuilder plugin. In custom plugin Plugin.php boot() method paste something like this:

Event::listen('formBuilder.beforeSendMessage', function ($form, $data) { DB::table('products')->insert( ['name' => $data['name'] );

   return true; // this will prevent sending email message

});

If you have Product model you can use it instead of Query Builder . You will have to know a little Laravel to do all of this.

Let me know if you want more help.

Hello Renatio,

What do you suggest how to assign different Events for different forms (made by FormBuilder)? I mean I would create a form for example for Products and an other form for Customers, when submitting form I can catch the event by listener (just as you wrote above) but how can I solve to save Products form data to Products model and Customer datas to Customers model? So how could I call different events? What would be the proper solution?

Thank you for your help!

Renatio
Renatio

Hi,

you have access to $form object in this event. There you can check for form code, which is unique.

Something like this:

Event::listen('formBuilder.beforeSendMessage', function ($form, $data) {
    if ($form->code == 'products_form') {
        // process products form
    } elseif ($form->code == 'customer_form') {
        // process customer form
    }

    return true; // this will prevent sending email message
});
Codebugs
Codebugs

It's great! Thank you for your prompt help!

phplee
phplee

Also is there a way to save the attachments to my order table rather that they be email via form builder.

thanks

goran.novacic21512
goran.novacic21512

Hi, can I add basket partial in the form?

Renatio
Renatio

@goran.novacic21512 I don't understand what you mean by that. Please open new ticket with more details what you are trying to do.

prema770
prema770

Thanks for this plugin. One of the best for us Can anyone post sample code for a custom plugin which intercepts the form in the way outlined above? Thanks in advance

1-10 of 10