FastUI icon indicating copy to clipboard operation
FastUI copied to clipboard

Support locked FormFields

Open rgimen3z opened this issue 1 year ago • 1 comments

Looks like BaseFormField was designed to support "locking"/"disabling" an input field: https://github.com/pydantic/FastUI/blob/cec25c61a7cc5a716d05d21039f95be3e8dac0e8/src/python-fastui/fastui/components/forms.py#L22

However, this is not working for me even after extending the json_schema_field_to_field() method to also pass an extra locked=schema.get('locked', False) param to the FormFieldInput in: https://github.com/pydantic/FastUI/blob/cec25c61a7cc5a716d05d21039f95be3e8dac0e8/src/python-fastui/fastui/json_schema.py#L182-L189

I'm not sure, but I think the problem may lie somewhere in the npm package around the below lines? https://github.com/pydantic/FastUI/blob/cec25c61a7cc5a716d05d21039f95be3e8dac0e8/src/npm-fastui/src/components/FormField.tsx#L37-L38

Anyone knows how to fix? Thanks in advance!

rgimen3z avatar Jan 30 '24 00:01 rgimen3z

I would try creating a FormFieldInput manually and seeing if you can get a field to lock. If so, it should be fairly easy to fix in JSON schema parsing.

samuelcolvin avatar Feb 09 '24 07:02 samuelcolvin