You are viewing limited content. For full access, please sign in.

Question

Question

Dynamically populate dropdown in new Forms designer using the LFForm object

asked on March 8, 2022 Show version history

I'm trying out the new forms designer on an internal build to try and get the hang of it and I've come across something I'm trying to do that I can't quite figure out. I'd like to dynamically populate a dropdown in the form based on the values input into a collection of single line fields earlier in the form. The setFieldValues in the LFForm object doesn't work for this - it will only set the selected value based on values that are already in the dropdown.

I'm finding it impossible to target anything correctly using jQuery and I'm assuming this is due to wanting us to use the LFForm object but I'm not seeing a way to do what I want to do. I'm wondering if anyone else has had any luck coding something like this or similar using the new designer? (This would be easily done in the classic designer so I might have to switch over to it if none of what I want to do is available in the new designer, but I'd like to work with it since it was implied that classic designer will be removed at some point).

1 0

Answer

SELECTED ANSWER
replied on April 17, 2024

It seems like they added this feature in under the changeFieldOptions for the LFForm object.

https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Subsystems/Forms/Content/Javascript-and-CSS/JavaScript-in-the-Forms-Designer.htm#changeFieldOptions

Just doing the following, added a new value to my dropdown

 

LFForm.changeFieldOptions({fieldId: 18}, [{label: "Choice 4"}], "add")


 

1 0

Replies

replied on March 8, 2022

Populate the dropdown choices with JavaScript is not supported for the new form designer, we will consider adding it in the future updates. 

We do recommend you use the new form designer if possible, but there is no current plan to remove the classic form designer since there are still use cases for it even with a built out modern form layout.

0 1
replied on June 4, 2023

Do we know if this is possible yet using the LFForm object?

1 0
replied on August 25, 2023

I too would like to know.  I am trying to auto populate a drop down option (no values assigned to the drop down options) using a variable value that comes from a single line field type.

1 0
replied on April 17, 2024

Are there any updates on being able to populate the dropdown choices with JavaScript in the modern form designer?

0 0
SELECTED ANSWER
replied on April 17, 2024

It seems like they added this feature in under the changeFieldOptions for the LFForm object.

https://doc.laserfiche.com/laserfiche.documentation/11/administration/en-us/Subsystems/Forms/Content/Javascript-and-CSS/JavaScript-in-the-Forms-Designer.htm#changeFieldOptions

Just doing the following, added a new value to my dropdown

 

LFForm.changeFieldOptions({fieldId: 18}, [{label: "Choice 4"}], "add")


 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.