ycv005
Jump to Particular Index in for loop Phoenix HTML?
How to look out for particular value in the For loop of the Phoenix HTML.
Like I only want to fetch out the 2nd candidate_pipeline from the @candidate_pipelines. How to do that? Your response will be highly appreciable. Note- Inside my for loop, the variable are depended on candidate_pipeline.
<%= for candidate_pipeline <- @candidate_pipelines do %>
<%= form_for get_candidate_update_changeset(candidate_pipeline), "#", [class: "d-inline", phx_change: "update_candidate_stage"], fn f -> %>
<input type="hidden" value="<%= candidate_pipeline.id %>" name="candidate_id"/>
<%= select f, :job_stage_id, Enum.map(@job_stages, &{&1.name, &1.id}), [class: "custom-select custom-select-sm"] %>
<% end %>
<% end %>
Most Liked
peerreynders
Get rid of the for comprehension and define a function in the view to do the work
<%= form_for second_changeset(@candidate_pipelines), "#", [class: "d-inline", phx_change: "update_candidate_stage"], fn f -> %>
<input type="hidden" value="<%= candidate_pipeline.id %>" name="candidate_id"/>
<%= select f, :job_stage_id, Enum.map(@job_stages, &{&1.name, &1.id}), [class: "custom-select custom-select-sm"] %>
<% end %>
For example you can pick the second element in a list this way:
iex(1)> second = fn [_, value| _] -> value end
#Function<6.128620087/1 in :erl_eval.expr/5>
iex(2)> list = [1,2,3]
[1, 2, 3]
iex(3)> second.(list)
2
iex(4)>
Example of defining view functions (page_view.ex) being used in index.html.eex
1
Popular in Questions
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
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
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
I have followed this StackOverflow post to install the specific version of Erlang.
And When I am running mix ecto.setup then getting fol...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
The documentation above suggests that while ...
New
Hi,
I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Other popular topics
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Using vs code and installed ElixirLS: support and debugger.
And I got an error popped up on start up says
Failed to run ‘elixir’ comma...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
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
Update:
How to use the Blogs & Podcasts section
You can post links to your blog posts or podcasts either in one of the Official Blog...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









