Page 1 of 1

Formbuilder Save Checkbox Group to LISE

Posted: Wed Jun 12, 2024 11:38 am
by webform
I have a FormBuilder form with a Checkbox group, which constitutes a Module Interface Field from a LISE Instance (LISEEquipment).

My FormBuilder form saves to another LISE Instance (LISEEmployee) where the field is set to be a LISE Instance Item (LISEEquipment) with item_id as Identifier and Sub Type is set to Chekcbox Group.

In the backend in the Item overview, I can see the selected values correctly, but when I click on the individual item, nothing is selected in the checkbox group.

So how do I get the individual checkboxes to be selected in the LISE Instance when creating from FormBuilder?

I can see in the MySQL table that the checkbox group values are stored as comma separated values in a record e.g. 5, 8, but if I select the checkbox group directly in my LISE Instance, 5 and 8 are stored in the MySQL table as individual records.
I assume that it is my UDT saving from FormBuilder that is the problem?

The part of the UDT that is saving to LISE:

Code: Select all

$obj->title = $params['title'];
$obj->alias = $alias; # we already have one
$obj->url = $url_prefix . '/' . $params['recid'] . '-' . preg_replace('/-+/', '-', $title);

foreach($params as $key => $value) {
  if(isset($obj->fielddefs[$key])){
    if($value != "[unspecified]"){
      $obj->$key = $value;
    }
  }
}

$mod->SaveItem($obj);

Re: Formbuilder Save Checkbox Group to LISE

Posted: Thu Jun 13, 2024 11:40 am
by WDJames
Hi,

This is my part of my UDT if I want to save checkboxes:

Code: Select all

foreach($params as $key => $value) {
   if(isset($obj->fielddefs[$key])){
      if($value != "[unspecified]"){
         if($key == "checkboxes"){
           $multi_result = explode(",", $params["checkboxes"]);
           $obj->checkboxes = $multi_result;
         }else {
           $obj->$key = $value;
         }
      }
   }
}
Replace "checkboxes" with the alias of your LISE field.

I hope this helps.

Thanks,

James

Re: Formbuilder Save Checkbox Group to LISE

Posted: Thu Jun 13, 2024 1:17 pm
by webform
Ahh! Thats very cool!

I'll try that. Thanks!