【发布时间】:2023-03-21 04:20:01
【问题描述】:
我有以下型号...
PageCategory
我在page_controller.ex 的new 操作中有以下代码
def new(conn, _params) do
changeset = Page.changeset(%Page{})
categories = Repo.all(Category)
render(conn, "new.html", changeset: changeset, categories: categories)
end
我在 page/new.html.eex 中有以下选择字段的代码
<div class="form-group">
<%= label f, :category_id, "Parent", class: "control-label" %>
<%= select f, :category_id, @categories ,class: "form-control" %>
</div>
它应该在选择字段中显示所有类别,以便我可以为页面选择一个类别,但不幸的是我无法找到问题。如果您有任何建议,请告诉我。
【问题讨论】:
标签: elixir phoenix-framework ecto