Can't add form with auto forms
I'm getting this error when setting up with auto forms.
Attempted to add a form at path: [:budget_allocations], but no
create_action was configured.
here is my action
and the form
58 Replies
Add the
type: :read
option to your add form call
Because youβre technically looking up one to relateso that works when I add the form when initially creating it, buth handling it on an event is giving a strange error
warning: the following fields are unknown when raising Ash.Error.Query.NoSuchFunction: [resource: Spendable.Transaction]
π€
that is very strange
thats just the warning though, not the actual error
what does the error itself look like?
oh I think I see something else in there about actor not existing as a function... let me dig into that
so it looks like user is no longer set as actor in handle_event
I have a change that is accessing the actor
π€
what on earth
So that warning looks like some problem with a filter statement being built somewhere
oh wait it is set... something else weird is going on
Is the primary read action on the destination resource doing some kind of filter?
I have something like this on all my resources
interesting, I haven't touched those, they all worked with graphql, I'm setting up a liveview app now
π€ that is surprising
That warning is from it constructing an invalid filter error
have you confirmed that the policies properly forbid incorrect users?
yes, I had tests explicity for that
hm...
ok the error is gone now, but no form is adding π
but
add_form
is returning successfully?it doesn't throw an error and just returns a form
π€ can you check the count of
form.forms[:budget_allocations]
?
before and after you add the formforms under form doesn't exist, I do see a forms key, trying to figure out what it is under
form.source.forms[:budget_allocations] does have the extra now...
hm...
could something be wrong with the way you're rendering the forms?
I don't think so, the one I add on form creation is showing up
if you add two on form creation do they both show up?
can you show me your template code?
there is an existing one that shows up, I add one through add_forms, but when I do the action it doesn't show up
oh, okay
so its showing up in the UI
but not when you submit?
its not showing up in the UI
are you reassigning the form and all that?
hmmmmm
It not showing up sounds very strange
I don't really see how that would happen π¦
ya this might be past Ash now, the form definitely has 3 now
inputs_for
should essentially just loop over each formoh the split button is sending a submit event...
ah, yeah you might need
type="submit"
sorry
type="button"
well it didn't submit this time.. but still no new form π
...wacky
π€
After you
add_form
you can inspect form[:budget_allocations]
is it maybe a problem with read and trying to create a new one?
I don't think so? its possible
so the first two in that are showing up, the form and second is added during handle_params, the third is added in handle_event
if I keep pushing split, those forms are continuing to be added to the assigns form, but the UI isn't updating
π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€ π€
did you confirm that adding additional forms on the initial form works?
ya I still have that piece in
thats so weird
I just pushed the file if you want to see everything in context https://github.com/michaelst/spendable/blob/2c730e2ba2135ea268b8b417fe91005f1943195e/spendable/lib/spendable_web/live/transactions.ex
GitHub
spendable/spendable/lib/spendable_web/live/transactions.ex at 2c730...
Budgeting app built on Phoenix and React. Contribute to michaelst/spendable development by creating an account on GitHub.
like the same code on the mount vs the same code in the handle event
ya
handle_event: https://github.com/michaelst/spendable/blob/2c730e2ba2135ea268b8b417fe91005f1943195e/spendable/lib/spendable_web/live/transactions.ex#L131
on mount (technically handle_params): https://github.com/michaelst/spendable/blob/2c730e2ba2135ea268b8b417fe91005f1943195e/spendable/lib/spendable_web/live/transactions.ex#L131
interesting, if I type into one of the fields it removes the other forms
and if I hit split it gets rid of what I typed
uh...okay something is definitely wrong
π
Something to do w/ the assigned form/validation step I'd assume
I've got to hit the sack, but if you find anything else of note let me know
ok, thanks for the help
I don't think the
type: :read
should be the problem
it feels like an issue w/ assigns/the validate step, not really sureoh let me try going back to not auto forms
yeah good idea to try
same result, also I diffed the forms of adding in handle_params vs the event and they are exactly the same, there is something wrong at the rendering layer that is not telling it that something changed
maybe try upgrading/downgrading phoenix liveview?
it was my custom change action π€¦ββοΈ
Ok with that commented out I'm still runing into some weird behavior with my inputs reseting, also my forms share a name between the resources and they appear to be changing each other. I can provide more details tomorrow
something is super strange is happening here then
maybe missing hidden inputs?
but IIRC the inputs_for component renders the hidden fields
okay, interesting
so the
value
in the example you sent me seems wrong
I think we might need to do something like this:
This may be a bug with the new phoenix pattern of inputs_for .... @form[:relationship]
anything I can help to test or implement? any other details you need?
If you could clone down
ash_phoenix
and try out that change to input_value
that would be great π
I wont be at my computer much given the holidayyep I can do that, totally understand
got this error
key :forms not found in: #Ash.Changeset<
on this line if form.source.forms[field] do
changed it to use phoenix_form
with that change it still resets my fields and is changing the parent amount field
I checked it does evaluate true and use that path
I'm so confused, but somehow it started working, I've been playing with the mange_relationship types, budget_allcations needed to be direct_control and revert back to type: :update
I definitely need to write a guide for this with a working configurationWhatttt
And yes, I agree, we need better guides on this one.