Create a Form with an Association

Learn how to create a Phoenix form with an association.

Now let’s tackle a more complex case—how to create a form with associations. We’ll use an embedded schema representing the user’s address to make it even more interesting. If you need to refresh your memory on schemas, associations, or embeds, you can flip back to this lesson before proceeding.

Creating an embedded schema

First, create an embedded schema for the user’s address along with a changeset function, as shown below.

Get hands-on with 1200+ tech skills courses.