tl_jacob
tl_jacob4w ago

App: Required input fields

What is the recommended way of validating input fields when a button is clicked and before the underlying script/flow is called? For example, I have an app with: - several text inputs - a button that triggers a script using the values from the text input fields - each of the text inputs should be non-empty for the script to run correctly I want to validate that the text inputs are non empty when a user clicks a button but BEFORE we call the script.
21 Replies
rubenf
rubenf4w ago
@tl_jacob why not use "live" validation instead and put the constraint on the form itself?
tl_jacob
tl_jacobOP4w ago
ah I haven't tried the form UI component! I've just been adding text inputs to containers. Thanks @rubenf ! @rubenf is it possible to use the Select or Multiselect components in a Form component? If not, is there a recommended workaround for using those components and maintaining the "live" validation of the form?
rubenf
rubenf4w ago
it's possible yes, string + enum, and array + array of string + multiselect
tl_jacob
tl_jacobOP4w ago
Okay I got Single select to work, but I'm having a small issue with Multiselect. Ideally I could link selected values to underlying IDs, but the array + array of string approach doesn't allow that (see screenshot). Am I approaching this incorrectly?
No description
tl_jacob
tl_jacobOP4w ago
No description
rubenf
rubenf4w ago
right now we don't support label + value for static multiselect
tl_jacob
tl_jacobOP4w ago
@rubenf okay understood! I need my multiselect + select fields to be dynamic based on other inputs. e.g. Selecting a company from the "company" drop down changes the options in the "office location" drop down. My current approach has been to wire together individual text/number/multiselect/select components. If we don't go with the Form approach, going back to my original question, is there a way to do some live validation? An approach I'm considering is to just create a custom frontend script that is recomputed anytime any of the fields changes. I think that will work, but just wanted to check to see if there are any other well-known/recommended approaches
rubenf
rubenf4w ago
@tl_jacob ah yes you can make them dynamic, but you need to make the jsonschema an expression you dynamically fill
rubenf
rubenf4w ago
not sure it works with "Dynamic Enum" for multi-select. If it doesn't we will add to backlog
No description
tl_jacob
tl_jacobOP4w ago
@rubenf cool! I can confirm that Dynamic Enum does not appear to work with multi-select. It would be really nice to support label + value for multiselect too please 🙏
rubenf
rubenf4w ago
I can take a look
rubenf
rubenf4w ago
@tl_jacob the enum can be dynamic, but just not with label + value:
No description
rubenf
rubenf4w ago
but it's normal, we can't handle multiple label with same values. But you should be able to do your own mapping
rubenf
rubenf4w ago
nvm we even support it:
No description
tl_jacob
tl_jacobOP4w ago
No description
tl_jacob
tl_jacobOP4w ago
@rubenf hmm my options are rendering as [object Object]
tl_jacob
tl_jacobOP4w ago
No description
No description
rubenf
rubenf4w ago
Select array And items are strings Then fill dynamic enums like me
tl_jacob
tl_jacobOP4w ago
@rubenf ah looked like a verison issue. I upgraded to 1.549.1 from 1.500.1 and multiselect works. However, single select shows [object Object] still
No description
rubenf
rubenf4w ago
I will look it up fixed on latest
tl_jacob
tl_jacobOP4w ago
amazing thank you so much @rubenf !

Did you find this page helpful?