Dynamic Field Validation from pre-defined Schema

Troubleshooting

Hi everyone.

I'm new to FlutterFlow, and I'm looking to see if I can use it to replace a legacy PWA.

I have a pre-defined JSON schema which defines a form. I have been able to dynamically render different types of input fields, with their associated metadata, which is good, but have run into a problem when it comes to dynamically validating those fields.

The JSON schema contains properties which specify if a particular question is required or not (and other validation information), but, because I am dynamically rendering the input fields as children of a list view, I am required to create individual components for each type of input. This is fine, it makes sense, but there are two validation problems:

  1. If I wrap the list view in a form widget, no validation options appear in the form widget's properties panel. I assume this is because the list can have anywhere from 0 to n entries, the form cannot access the inner inputs as they themselves end up inside containers, and there are also conditional visibility statements as well.

  2. If I instead wrap in the input fields inside the components with a form widget, the validation options do appear in the form widget's properties panel, but none of the options can be set dynamically from a value. This means that I can only have validation either on or off, and not dynamic.

Here is an example:

A) JSON Schema for 1 question in the form.

{
  "id": 0,
  "hint": "",
  "type": "singleLineInput",
  "label": "PIN",
  "required": true,
  "min_len": 5,
  "max_len": 5,
  "response": null,
  "responseType": "number"
}

The issue is that I can't find any way to provide the required, min_len and max_len property values to the validation control.

B) The validation control

The options are there, but I cannot provide dynamic values.

Is there some other way of doing form/input validation?

In a similar vein, the JSON schema also defines a response type, in this example, number, but I also cannot dynamically set the keyboard type.

C) Keyboard properties

Any help would be appreciated.

What have you tried so far?

I have read the docs and a lot of other posts about form validation, but I have not found an answer.

Did you check FlutterFlow's Documentation for this topic?
Yes
1
1 reply