From 8874e0e7ba78a3bb3ad71fe659d757a5631a41b9 Mon Sep 17 00:00:00 2001 From: Inhji Date: Tue, 7 Mar 2023 19:57:28 +0100 Subject: [PATCH] turn post kind field into enum --- lib/chiya/notes/note.ex | 2 +- lib/chiya_web/controllers/note_html/note_form.html.heex | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/chiya/notes/note.ex b/lib/chiya/notes/note.ex index a86a9bb..e785246 100644 --- a/lib/chiya/notes/note.ex +++ b/lib/chiya/notes/note.ex @@ -4,7 +4,7 @@ defmodule Chiya.Notes.Note do schema "notes" do field :content, :string - field :kind, :string + field :kind, Ecto.Enum, values: [:post, :bookmark] field :name, :string field :published_at, :naive_datetime field :slug, :string diff --git a/lib/chiya_web/controllers/note_html/note_form.html.heex b/lib/chiya_web/controllers/note_html/note_form.html.heex index 0a0d6fb..a8bd7c3 100644 --- a/lib/chiya_web/controllers/note_html/note_form.html.heex +++ b/lib/chiya_web/controllers/note_html/note_form.html.heex @@ -6,7 +6,13 @@ <.input field={f[:content]} type="textarea" label="Content" /> <.input field={f[:slug]} type="text" label="Slug" /> <.input field={f[:published_at]} type="datetime-local" label="Published at" /> - <.input field={f[:kind]} type="text" label="Kind" /> + <.input + field={f[:kind]} + type="select" + label="Kind" + prompt="Choose a value" + options={Ecto.Enum.values(Chiya.Notes.Note, :kind)} + /> <.input field={f[:url]} type="text" label="Url" /> <.input field={f[:channels]}