I pasted the values in csv file and in select. How can I delete the selected values from select?
Here’s the code
contact.ex:
schema "contacts" do
field :iban, :string:
timestamps()
end
def changeset(contact, attrs) do
contact
|> cast(attrs, [:iban]) end
contact_view.ex:
def random_index(list) do
:rand.seed(:erlang.now())
Enum.random(0..length(list) - 1)
end
def random_iban(assigned_iban) do
ibans = File.stream!("priv/data/virtuelleskonto.csv") |> Enum.to_list()
index = random_index(ibans)
case List.delete_at(ibans, assigned_iban) do
{iban, _rest} ->
{iban, ibans}
_ ->
random_iban(assigned_iban)
end
end
form.html.heex:
<div class="col">
<%= label(f, :iban, "IBAN", class: "form-label") %>
<%= select(f, :iban, random_iban(f.object.iban) ,
prompt: "Wählen Sie ein Konto",
class: "form-select") %>
<%= error_tag(f, :iban) %>
</div>
Can anyone help me?