kodi

kodi

Only the title, location, and description fields are showing in the form. The option_date field is not showing in the browser.

Poll schema:

defmodule Rallly6.PollingSystem.Poll do
use Ecto.Schema
import Ecto.Changeset

alias Rallly6.PollingSystem.Option

@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema “polls” do
field :description, :string
field :title, :string
field :location, :string
field :time_zone, :naive_datetime
field :is_closed, :boolean, default: false
field :is_deleted, :boolean, default: false
field :disable_comments, :boolean, default: false
field :user_id, :binary_id
has_many :options, Option

timestamps(type: :utc_datetime)

end

@doc false
def changeset(poll, attrs) do
poll
|> cast(attrs, [:title, :description, :location, :time_zone, :is_closed, :is_deleted, :disable_comments])
|> cast_assoc(:options, with: &Option.changeset/2)
|> validate_required([:title, :description, :location, :time_zone, :is_closed, :is_deleted, :disable_comments])
end
end

Option schema:

defmodule Rallly6.PollingSystem.Option do
use Ecto.Schema
import Ecto.Changeset

alias Rallly6.PollingSystem.Poll

@primary_key {:id, :binary_id, autogenerate: true}
@foreign_key_type :binary_id
schema “options” do
field :option_date, :date

belongs_to :poll, Poll


timestamps(type: :utc_datetime)

end

@doc false
def changeset(option, attrs) do
option
|> cast(attrs, [:option_date, :poll_id])
|> validate_required([:option_date])
end
end

form component:

<.header> <%!-- <%= @title %> --%> <:subtitle>Use this form to manage poll records in your database.
  <.simple_form
    for={@form}
    id="poll-form"
    phx-target={@myself}
    phx-change="validate"
    phx-submit="save"
  >


  <.input field={@form[:title]} type="text" label="Title" />
  <.input field={@form[:location]} type="text" label="Location" />
  <.input field={@form[:description]} type="text" label="Description" />

  <.inputs_for :let={opt_nested} field={@form[:options]}>


    <.input field={opt_nested[:option_date]} type="date" label="date" />

  </.inputs_for>


    <:actions>
      <.button phx-disable-with="Saving...">Save Poll</.button>
    </:actions>
  </.simple_form>
</div>

In the above form component, the:option_date is not showing in the browser. I need help in fixing it

First Post!

03juan

03juan

Hello and welcome to the community.

How are you creating the @form assigns in your controller?

Where Next?

Popular in Questions Top

srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Kagamiiiii
Student &amp; New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement