-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70fa970
commit 9f18c5d
Showing
3 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!-- | ||
This file was generated by Spark. Do not edit it by hand. | ||
--> | ||
# DSL: AshPhoenix | ||
|
||
An extension to add form builders to the code interface. | ||
|
||
This defines a `form_to_<name>` function for each code interface | ||
function. Positional arguments are ignored, given that in forms, | ||
all input typically comes from the `params` map. | ||
|
||
The generated function passes all options through to | ||
`AshPhoenix.Form.for_action/3` | ||
|
||
Update and destroy actions take the record being updated/destroyed | ||
as the first argument. | ||
|
||
For example, given this code interface definition on a domain | ||
called `MyApp.Accounts`: | ||
|
||
```elixir | ||
resources do | ||
resource MyApp.Accounts.User do | ||
define :register_with_password, args: [:email, :password] | ||
define :update_user, action: :update, args: [:email, :password] | ||
end | ||
end | ||
``` | ||
|
||
Adding the `AshPhoenix` extension would define | ||
`form_to_register_with_password/2`. | ||
|
||
## Usage | ||
|
||
Without options: | ||
|
||
```elixir | ||
MyApp.Accounts.form_to_register_with_password() | ||
#=> %AshPhoenix.Form{} | ||
``` | ||
|
||
With options: | ||
|
||
```elixir | ||
MyApp.Accounts.form_to_register_with_password(params: %{"email" => "placeholder@email"}) | ||
#=> %AshPhoenix.Form{} | ||
``` | ||
|
||
With | ||
|
||
```elixir | ||
MyApp.Accounts.form_to_update_user(params: %{"email" => "placeholder@email"}) | ||
#=> %AshPhoenix.Form{} | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
<style type="text/css">.spark-required::after { content: "*"; color: red !important; }</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters