iyjim
Ash.Resource — ash v3.5.2 says that the default value can be a zero arity function e.g. &MyMod.my_fun/0 or a value.
What if the default argument value should depend on the actor? Is there a way to get the actor in the zero arity function?
Please help.
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ken-kost
Why make a dynamic value dependent on actor to be default?
I think you could do something like:
You can
dbgchangeset and context. Make sure to pass the actor in your action call in options.Not sure if best approach though
Perhaps Zach will have a better idea. 
iyjim
Thanks @ken-kost for your reply.
We are building some internal used system, and would like to provide dynamic default values for different actors (roles actually) on forms.
For some reason, we got to use generic action, so we got to use the AshPhoenix.Form.for_action(). But when we try to set dynamic default value of a form using Ash.ActionInput.set_argument(input, :arg1, value1) in :prepare_source option, we don’t see any different on the form. That’s why I asked the way to set the dynamic default value in the “default” option.
Fortunately, when we use %Ash.ActionInput{input | arguments: %{arg1: value1}} in :prepare_source option to set dynamic default values, it works! And since we can get actor in the :prepare_source option when calling AshPhoenix.Form.for_action(), this issue is resolved.
I’m just wondering:
zachdaniel
Those should be for all intents and purposes the same thing. I’m not really sure why one would work and one wouldn’t
It is the trouble with
action_inputis that they don’t have a concept of preparations/changes the way that queries do. This is something I’d like to change in the future. What you can do to make things a bit simpler is just set the default in the params when creating the form. Would that work? i.eForm.for_action(..., params: %{"default" => "values"})iyjim
Thank you for your prompt reply. But the :params option in Form.for_action() get this error msg:
It looks better if Form.for_action() has this :params option though.
zachdaniel
I think this may be a bug? Can you open an issue with examples of your code and stack traces of the error etc. on
ash_phoenixken-kost
Could you print your input? Reasons for the skip might be if input does not have action key and that action has to have arguments in which one of them is the sent one i.e.
Enum.findis used.AFAIS
for_calls do not have params option.zachdaniel
Oh you’re right, you’d want to validate once with params after calling the action, sorry
my inner LLM hallucinated that one 
zachdaniel
Hmm…looking at the code, I wasn’t hallucinating. There definitely should be a
paramsoption when creating new forms. I tried it myself just recently and it workediyjim
Thanks for your kindly help.
I’m faceing a deadline on some work, so the example to reproduce the error will be created later next week.
If a simple example will work without error, I might have to revisit my code to see the differences, like arguments with default value or so, and apply them to this simple example, so it might need some more works to reproduce the error.
Thank you very much!
ken-kost
I does indeed work but it’s not mentioned in the docs or rather in
@for_options. But what’s weird is the error(Spark.Options.ValidationError) unknown options [:params]becausevalidate_opts_with_extra_keysis used where params ends up in extra keys that are not spark validated and are merged with validated for options. Weird