You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For operations, I mean add, delete, update, insert form field values.
How conform can do operations currently
It's currently possible to do operations programmatically by form.update, form.remove etc. Not directly but documented in Intent button.
To do programatic operations on a field:
The field should be exist on DOM, maybe by a <input type='hidden'/>
If the field is a nested field, we need to have all <input />s down to primitive level
A form.update can then behave correctly
All about logic should be as is because conform is storing value on element, not react state.
Gotcha about (hidden) input and try to facilitate it
If you have fields that should be filled programmatically, like the position of a draggable area, it's a gotcha to remember to put a lot <input type='hidden' /> that matches the form of your fields. But once you put all <input type='hidden' /> correctly. A form.update will act as expected.
Then, I decide to make a helper to the hidden input, which is tedious and error-prone:
I was surprised by my self I can do that recursion 🤣
conform uses proxy and it might not be possible to retrieve nested fields
The recursion is beautiful right? But it doesn't wok. Turns out it's because conform use proxy to access form and fields. 'getFieldList' in field or 'getFieldset' in field would always be false. Though I can do field.getFieldList(), field.getFieldset(), which are always there, but the real challenge is that I couldn't loop through a field.getFieldset() to get all its keys.
Ask
If there is a way to retrieve all props of conform's proxy?
Is conform has any utility function to retrieve all key of a object field?
What is it to use proxy in first place? Could that be rewritten?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For operations, I mean add, delete, update, insert form field values.
How conform can do operations currently
It's currently possible to do operations programmatically by
form.update
,form.remove
etc. Not directly but documented in Intent button.To do programatic operations on a field:
<input type='hidden'/>
<input />
s down to primitive levelform.update
can then behave correctlyAll about logic should be as is because conform is storing value on element, not react state.
Gotcha about (hidden) input and try to facilitate it
If you have fields that should be filled programmatically, like the position of a draggable area, it's a gotcha to remember to put a lot
<input type='hidden' />
that matches the form of your fields. But once you put all<input type='hidden' />
correctly. Aform.update
will act as expected.Then, I decide to make a helper to the hidden input, which is tedious and error-prone:
I was surprised by my self I can do that recursion 🤣
conform uses proxy and it might not be possible to retrieve nested fields
The recursion is beautiful right? But it doesn't wok. Turns out it's because conform use proxy to access form and fields.
'getFieldList' in field
or'getFieldset' in field
would always befalse
. Though I can dofield.getFieldList()
,field.getFieldset()
, which are always there, but the real challenge is that I couldn't loop through afield.getFieldset()
to get all its keys.Ask
Beta Was this translation helpful? Give feedback.
All reactions