Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting actor in nested forms #99

Closed
puruzio opened this issue Sep 4, 2023 · 1 comment
Closed

Setting actor in nested forms #99

puruzio opened this issue Sep 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@puruzio
Copy link

puruzio commented Sep 4, 2023

Describe the bug
A clear and concise description of what the bug is. If you are not sure if the bug is related to ash or an extension, log it with ash and we will move it.

This may be a user error rather than a bug, but I'm porting an issue here per Zach's guidance.

The user info set into the process with Ash.set_actor is only accessible from the main form's (create/update) actions, but not from its sub-forms'. In the sub-forms' action, actor returns nil.

To Reproduce
A minimal set of resource definitions and calls that can reproduce the bug.

Run Ash.set_actor(current_user) in a liveview's mount function and check the value of actor in the create action of a sub-form to observe its value being nil.

Expected behavior
A clear and concise description of what you expected to happen.

actor should return the user info set by Ash.set_actor across different nested forms.

** Runtime

  • Elixir version 1.14.1
  • Erlang version Erlang/OTP 25
  • OS Windows 11
  • Ash version 2.13.3
  • any related extension versions

Additional context
Add any other context about the problem here.

Setting actor as follows, without using Ash.set_actor in the mount function, causes a nil actor value in every form's action including the main form's. Again, this may be a user error, but mentioning it here in case this problem is somehow related to the main issue reported above.


AshPhoenix.Form.for_update(post, :create,
    api: MyAPI,
    actor: current_user,
    forms: [
         comments: [
              resources: Comment,
               ...
@puruzio puruzio added the bug Something isn't working label Sep 4, 2023
@zachdaniel
Copy link
Contributor

This should be fixed in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants