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

Nested Form Fields #207

Open
alvnrapada opened this issue Jun 10, 2021 · 1 comment
Open

Nested Form Fields #207

alvnrapada opened this issue Jun 10, 2021 · 1 comment
Labels
enhancement New feature or request planned

Comments

@alvnrapada
Copy link

alvnrapada commented Jun 10, 2021

How do you achieve nested form fields (like: inputs_for/2)?

Ex: When creating User, I also want to create contacts

Schema

  schema "users" do
    field :username, :string
  
    # Associations
    has_many(:contacts, Contact)
  end


   def assoc_changeset(user, attrs \\ %{}) do
    user
    |> cast(attrs, [:username])
    |> cast_assoc(:contacts, with: &Contact.changeset/2)
  end

Kaffy

defmodule MyApp.UserAdmin do

  def create_changeset(schema, attrs) do
    MyApp.User.assoc_changeset(schema, attrs)
  end

  def form_fields(_) do
    [
      username: %{label: "Username (Required)"},
      contacts:  %{
        # IS THIS POSSIBLE?
      }
    ]
  end

end

Can this be achieved just by using form_fields

@aesmail aesmail added the enhancement New feature or request label Nov 3, 2021
@aesmail
Copy link
Owner

aesmail commented Nov 3, 2021

Hello @alvnrapada
It's been a while, but this is not supported currently. It would be a nice feature though for future releases.
I'll keep this open for now just as a reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request planned
Projects
None yet
Development

No branches or pull requests

2 participants