Formbuilder Save to LISE Topic is solved

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: 69
Joined: Tue Feb 13, 2018 1:09 pm

Formbuilder Save to LISE

Post by WDJames »

Hello,

I'm using Formbuilder to create a form that saves submissions into LISE (profiles). I'm now trying to add the functionality to edit previously created profiles which works by taking the profile variables and pass it onto the same Formbuilder form which created it.

My issue is that I am needing to fill in every field again (as opposed to only editing the relevant fields) as Formbuilder overwrites all the data within the profile. I realise that all the fields would be filled in anyway because I am passing the data into the form but this doesn't work with fIles. Basically, I want the user's profile picture to stay the same if the form field is left blank. I suppose I can edit my UDT so that it checks the current LISE item value against the new value from the form submission but I'm not sure if this would work.

Does anyone have any ideas?

Thanks,

James
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1946
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder Save to LISE

Post by Jo Morg »

Not sure I understand the question but, from what I could gather:
  1. if you have the item_id from the record you want to edit you can pull all its values from LISE easily and assign them to an array that you can then use to pre-fill the fields;
  2. file inputs are a particular issue because the browser can't pre-fill them for security reasons, so there is no easy way around it;
Regarding point b I'd need way more data to be able to help as there are workarounds, not all simple if any, and depending on the requirement and your comfort with PHP, Smarty, and Javascript.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
WDJames
Forum Members
Forum Members
Posts: 69
Joined: Tue Feb 13, 2018 1:09 pm

Re: Formbuilder Save to LISE

Post by WDJames »

Hi Jo,

Thanks for getting back to me so quickly and apologies for the confusion.

I am able to pass the info from LISE back to FormBuilder EXCEPT the File Input value. What I'm trying to achieve is to keep the current value of the File Input field when the form is submitted and the File Input field is blank. At the moment, the File Input field is being overwritten on submission removing the current value.

I am comfortable with code so feel free to point me in the right direction.

Thanks,

James
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1946
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder Save to LISE

Post by Jo Morg »

Cool! In that case I would suggest the following:
Add to the form a non-persistent checkbox that appears only when there is a value on that field and name it anything like

Code: Select all

{action_id}delete_this_field_value
(less is more I'll leave the naming and labeling to you :) ). On your UDT check if the delete checkbox is selected, and if it is, you can either overwrite the value or just delete it (and probably need to do some file cleaning on the process, I'll leave that to you). Probably the deletion is not different than default behavior if the field itself is left empty. However, imo, you should always do some housekeeping with regards to the physical files on the UDT, otherwise you may be collecting garbage on each edit and eventually have conflicting filenames etc...
HTH
P.S.: note that if the checkbox is not selected you can just ignore the field and not set it at all, just to be clear :)
Last edited by Jo Morg on Fri Jun 07, 2024 12:12 pm, edited 1 time in total.
Reason: missing a clarification
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
WDJames
Forum Members
Forum Members
Posts: 69
Joined: Tue Feb 13, 2018 1:09 pm

Re: Formbuilder Save to LISE

Post by WDJames »

Hi Jo,

Thanks again for your help.

I think I understand what you are suggesting and correct me if I am wrong but this is how I interpret your suggestion.

1. Add a "Replace/Delete Image" checkbox on my form.
2. On my UDT check the value of "Replace/Delete Image" and then either replace or do nothing.

I think this will work, however I am using the same form to create and edit the profile so I will have to hide the checkbox when the user is creating a profile and only show when they are editing. I could just create a separate form for editing the profile so this wouldn't be an issue or use CSS to hide the checkbox.

The alternative is to do something like this on my UDT:

Code: Select all

$Image = $obj->Image;

if (isset($Image) && !empty($Image)){ // If theres an image already

 if (isset($params['Image']) && !empty($params['Image'])) { // If the form has a new value then replace
   $obj->Image = $params['Image'];
 }
}else{ //else add
 $obj->Image = $params['Image'];
}
Thanks,

James
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1946
Joined: Mon Jan 29, 2007 4:47 pm

Re: Formbuilder Save to LISE

Post by Jo Morg »

Sorry for the late reply.
WDJames wrote: Fri Jun 07, 2024 2:00 pm I think I understand what you are suggesting and correct me if I am wrong but this is how I interpret your suggestion.

1. Add a "Replace/Delete Image" checkbox on my form.
2. On my UDT check the value of "Replace/Delete Image" and then either replace or do nothing.
Correct on both.
WDJames wrote: Fri Jun 07, 2024 2:00 pm I think this will work, however I am using the same form to create and edit the profile so I will have to hide the checkbox when the user is creating a profile and only show when they are editing. I could just create a separate form for editing the profile so this wouldn't be an issue or use CSS to hide the checkbox.
Just check for the existence of an {$item->item_id > 0} to determine if you are editing or creating a new instance.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Post Reply

Return to “Modules/Add-Ons”