Page 1 of 1

CGBetterForms and LISE

Posted: Thu Apr 25, 2019 11:17 am
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

Re: CGBetterForms and LISE

Posted: Thu Apr 25, 2019 1:26 pm
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);

Re: CGBetterForms and LISE

Posted: Thu Apr 25, 2019 2:18 pm
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.