Providing changeset of associate in form template

What I am trying to do:

I’m trying to create a form so that users can submit perfume record. The create action will create the perfume and it’s associations.

Here’s my error:

** (CompileError) lib/fumigate_web/templates/admin/perfume/form.html.eex:34: Company.struct/1 is undefined, cannot expand struct Company

My perfume schema have changeset assoc to company.

   7   schema "perfumes" do
   8     field :concentration, :string
   9     field :day_released, :integer
  10     field :gender, GenderEnum
  17     many_to_many :companies, Fumigate.Fragrance.Company, join_through: Fumigate.              Fragrance.PerfumeCompanyJoin
  23     timestamps()
  24   end
  26   @doc false
  27   def changeset(perfume, attrs) do
  28     perfume
  29     |> cast(attrs, [:perfume_name, :concentration, :gender, :perfume_description, :           picture_url, :year_released, :month_released, :day_released])
  30     |> cast_assoc(:companies)
  33     |> validate_required([:perfume_name, :gender, :perfume_description])
  34   end

My controller:

>   18   def new(conn, _params) do
>   19     changeset = Fragrance.change_perfume(%Perfume{})
>   20     render(conn, "new.html", changeset: changeset,

My template:

  33       <div class="col-md-8">
  34         <%= inputs_for f, :companies, [append: [%Company{}]], fn fa -> %>
  35         <% end %>
  36       </div>

The problem is the template isn’t recognizing [append: [%Company{}]].

How do I fix this?

Thanks for your time.

Hi @mythicalprogrammer,

You need to use the full Module Name for the struct…

I have found a article in the internet that might be helpful in your case: