Hidden input field?

It seems to make more sense to generate a hidden field for ID's rather than a disabled text field? Any idea how to do this? I've tried changing <TextField> to type='hidden' but I still have stuff rendering on the form.
No description
13 Replies
kapa.ai
kapa.ai3y ago
Hey @johnwards! I'm the kapa.ai support bot. I've searched through the docs to try to answer your question. :wave:
kapa.ai
kapa.ai3y ago
---------------------- Hmm, I don't know enough to give you a confident answer yet. However, you can find more information about how to create a hidden input field in the Ant Design documentation (https://ant.design/components/form/#Form.Item). ----------------------
kapa.ai
kapa.ai3y ago
<@128446913274970112> kapa.ai is still learning and improving, please let us how it did by reacting below
harsh-harlequin
harsh-harlequinOP3y ago
Think it probably should generate this? For MUI. <InputBase {...register("id")} type="hidden" name="id" />
evident-indigo
evident-indigo3y ago
When you mean generate you mean inferecer code ?
harsh-harlequin
harsh-harlequinOP3y ago
Yeah sorry!
evident-indigo
evident-indigo3y ago
I understand. Inferencer designed to speed up development workflow. You can copy and customize your code to according to your needs
harsh-harlequin
harsh-harlequinOP3y ago
Yeah I get that, but was thinking that ID as a hidden field seems like the most obvious default? Been a while since I used a CRUD generator, but that was what I was expecting.
Omer
Omer3y ago
Hey @johnwards , please follow react-hook-form official docs. You can search for "hidden" in the document. thank you https://react-hook-form.com/api/useform/
useForm
Performant, flexible and extensible forms with easy-to-use validation.
harsh-harlequin
harsh-harlequinOP3y ago
Yeah think I've figured it out. I've sort of moved on to pondering if the CRUD generator should be generating these ID fields as hidden fields by default? eg a future change request?
conscious-sapphire
conscious-sapphire3y ago
Hello @johnwards , nice idea! Could you create an issue on GitHub with some details?
evident-indigo
evident-indigo3y ago
btw @johnwards, you can filter fields like this. it will be not rendered on ui
<AntdInferencer
fieldTransformer={(field) =>
field.key === "id"
? undefined
: field
}
/>
<AntdInferencer
fieldTransformer={(field) =>
field.key === "id"
? undefined
: field
}
/>
harsh-harlequin
harsh-harlequinOP3y ago
Cool!

Did you find this page helpful?