Adding to an array field outside of the field.
I have a separate button that I want to populate the field that isn't inside the field. How would I go about inserting it?
14 Replies
absent-sapphire•5mo ago
the form api also lets you access field setting methods, they‘re just named slightly differently
setFieldValue, pushFieldValue etc
continuing-cyanOP•5mo ago
I see, how can i access the form api in a button?
Oh wait
I found it, thanks for that!
absent-sapphire•5mo ago
:PepeThumbs:
in case someone finds this chatlog, it's just the returned value from
useForm
continuing-cyanOP•5mo ago
yes exactly that
Is there any way to make it generic and not tailored to a specific form?
absent-sapphire•5mo ago
at the moment, not unless you make it a form context, which you‘ve observed does not allow access to keys
continuing-cyanOP•5mo ago
Yeah haha
absent-sapphire•5mo ago
there‘s talk about a form group API or allowing withForm to extend the fields, but as it is right now, it‘s not a thing
continuing-cyanOP•5mo ago
Got it
absent-sapphire•5mo ago
I could suggest alternatives, but it‘s difficult to figure out what your desired behaviour is
continuing-cyanOP•5mo ago
Well let’s just I have 10 fields.
I want the first page to have 3 of them and the next button to validate those 3 fields.
The next page the next 3
Maybe I just need different forms. I will have to see how to connect them then
absent-sapphire•5mo ago
so if the fields are invalid, it won't let you click next?
Sounds like separate forms could work quite well here
since you can assume that previously passed data is correct, the next loaded element can accept data as parameter, knowing it's correct
continuing-cyanOP•5mo ago
Yes, but the only thing is I want to be able to go back and be able to change my results from the previous page
absent-sapphire•5mo ago
how about a two-dimensional array then? to separate them into page groups
then you could validate the „field“ which will be an array of values, in your case the values of the current page
continuing-cyanOP•5mo ago
That theoretically would work