alfredfriedrich
Hello,
first time playing around with Ash and hitting a wall. I’m trying to use a calucate in a form field. Lets say I have an attribute :duration, :integer and an attribute :duration_unit, :duration_name in a resource, and a calculate :duration_option, expr(duration <> " " <> duration_unit).
If I try to use the duration_option in a form field, I’m only getting a generic error from AshPhoenix.Form.submit.
I’ve looked at the custom composable types, but I’m using AshSqlite and it does not support this.
I guess “I’m using it wrong”, could someone point me at the “Ash” direction, please? ![]()
Thanks alfred
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #ai
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sevenseacat
Without knowing what your form looks like or what error you’re seeing, its hard to know what your issue might be! Can you share those, as well as what you’re trying to do?
ken-kost
Okay, so the expression might be the issue:
Also, I’m confused about using
duration_optionin a form field; don’t you mean the form should support entry of attributes that are used in calculation, not the calculation it self.?alfredfriedrich
Thank you for your reply, excuse my brevity, my resource looks like this:
and in my LiveView I create the form:
The error is, that duration and duration_unit are required fields.
I’m trying to use a select field with two database/resource attributes and want to populate the attributes from one virtual field.
In the pre-Ash era, I would’ve parsed the returned form value and written the result to the changeset (direction to db) or joined it for the form field value (direction from db).
The Composite Type in Ash looks exactly like that, but unfortunately AshSqlite does not seem to support those.
I guess
calculationsare only for the direction from db case?alfredfriedrich
I want to create a virtual form field (select) which populates, and is populated from two resource attributes, I hope my other answer to
sevenseacatmake my use case clearer to understand.ken-kost
I understand now.
So if you put in the form the required fields and send them to submit the error would be resolved. Then you could get that submitted entry and load the calculation.
But from what I gather you want the other way. You could parse
datainto params that have required field.zachdaniel
Calculations are likely not the fit here. You are likely looking for arguments. In your create action:
alfredfriedrich
Thank you, if I understand this correct, I’d have to call the
:createaction with the value ofduraction_optionfrom the form as an argument?Regarding
:reading from the database, would that also work witharguments?Feel free to let this problem rest for a while, I understand I need to read more (and more…, and the book too)
Thanks for all the responses.
zachdaniel
You can use arguments on reading yes. it is also possible that you want the calculation for display still. The main thing is that nothing will “reverse engineer” the underlying attributes by virtue of trying to change the calculation. You’ll need arguments for that.
alfredfriedrich
I’ll ponder over that.
alfredfriedrich
I read a little more in the Ash Framework book and in chapter 2 they use the
transform_paramsoption to theform_to_create_resourcecall, so I tried it like this:This works for me as expected, as I understand it, if I’d use
argumentandchangeit would work on theAsh.Changeset, but as far as my example goes, working on the params directly is good for me.I used the
calculationtoo for the<select>form field value by the way.Thanks again, this was fun playing around with
I will definitely use this on my next project.