CGBetterForms and LISE

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

CGBetterForms and LISE

Post by WDJames »

Hi all,

I've recently started using CGBetterForms as a replacement for FormBuilder.

With FormBuilder I was able to take the form data and insert it to LISE via a UDT.

I've tried to follow the help page from CGBetterForms and used the "Stop processing dispositions based on a condition" disposition and within that template called my UDT.

I can confirm that the UDT is being triggered but I need a way of getting the form submission values into the UDT. For my test, I'm using the Sample contact form with the following fields: name, email, comments.

Below is my UDT:

Code: Select all

$mod = cmsms()->GetModuleInstance('LISEContactFormDatabase');
if(!is_object($mod))
return;

$obj = $mod->InitiateItem();

$obj->title = $name;

$mod->SaveItem($obj);
The code above submits the form but the "$name" variable is blank and no LISE item is created.

Any ideas would be greatly appreciated.

Thanks,

James
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGBetterForms and LISE

Post by velden »

A working example (shortened):

Note I use some GUID (cgbf_requestid) generated by CGBF as an alias. Works for my case, but may be you need something different.

Code: Select all

{UDTNameHere formdata=$response}

Code: Select all

$d = $params['formdata'];

$mod = \cms_utils::get_module('LISEExample');

$item = $mod->LoadItemByIdentifier('alias', $d->get_field_value('cgbf_requestid'));

$item->email = $d->get_field_value('kfrm_p_inp_email');
$item->thema = $d->get_field_value('kfrm_inp_theme');
$item->datum = strftime('%Y-%m-%d',$d->get_field_value('kfrm_inp_date'));

$mod->SaveItem($item);
WDJames
Forum Members
Forum Members
Posts: 64
Joined: Tue Feb 13, 2018 1:09 pm

Re: CGBetterForms and LISE

Post by WDJames »

Hi Velden,

Thanks for the reply and for providing an example. I was able to make it work with my code by taking some things from your example. Below is what I ended up with:

UDT:

Code: Select all

{savecontactformdata formdata=$response}
Code:

Code: Select all

$d= $params['formdata'];

$mod = cmsms()->GetModuleInstance('LISEContactFormDatabase');
if(!is_object($mod))
return;

$obj = $mod->InitiateItem();

$obj->title = $d->get_field_value('name');
$obj->email = $d->get_field_value('email');
$obj->comments = $d->get_field_value('comments');

      
$mod->SaveItem($obj);
If I'm being cheeky, I'd like to expand on this code by adding a foreach loop that cycles through the LISE fields and insert data from the equivalent inputs so that each field doesn't need to written separately.

Thanks for your help.
Post Reply

Return to “Modules/Add-Ons”