Virtual field in Ash attribute

What's the Ash way to handle virtual fields often used for inputs that are not persisted?
7 Replies
frankdugan3
frankdugan33y ago
Generally, you will want to use arguments on the action itself.
frankdugan3
frankdugan33y ago
Ash HQ
DSL Section: ash > Resource > actions
View the documentation for DSL Section: ash > Resource > actions on Ash HQ.
Jason
JasonOP3y ago
So in this password string -> hash password example, how is the password included in the changeset as an attribute to show on a form?
frankdugan3
frankdugan33y ago
The changeset will include both attributes (controlled by accept [:attr, ...], defaulting to all public, writeable attributes) and arguments. You will want to use AshPhoenix.Form to mange it, as Ash changesets are different than Ecto changesets. https://ash-hq.org/docs/module/ash_phoenix/latest/ashphoenix-form
Ash HQ
Module: AshPhoenix.Form
View the documentation for AshPhoenix.Form on Ash HQ.
Jason
JasonOP3y ago
Okay. so both password and hashed password are attributes with no distinction of virtual : true or false. Got it. Thank you!!
frankdugan3
frankdugan33y ago
For Ash, attributes are persisted in the data layer, whereas arguments are ephemeral, only existing in the changeset.
Jason
JasonOP3y ago
Okay. I will read the doc more about arguments. thanks.

Did you find this page helpful?