ycv005

ycv005

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 %> 

Showing Posts 1 to 10

LostKobrakai

LostKobrakai

Look for the part about “filters”.

ycv005

ycv005 OP

Can you give me example to how to fetch out nth index value from the For Loop?

LostKobrakai

LostKobrakai

You can’t but you can use Enum.with_index to add indexes to your list of items.

ycv005

ycv005 OP

I have used the Enum.at but the problem is that I can’t then use the attribute of the candidate_pipe. For example, then I can’t use the candidate_pipeline.id. Could you solve the above part either by anyway? Note- I have the index value.

Or there is something like this- <%= candidate_pipeline = @candidate_pipelines[index] %>. So that values which will be stores into the variable and further I can access attribute values like candidate_pipeline.id.

kokolegorille

kokolegorille

It is not the functional way to proceed.

There are no loops, and using index to get Enum.at is not really efficient.

Something like taking each 2 elements should be done with filter.

What do You really want to do?

ycv005

ycv005 OP

I want to fetch out the particular element present at a index value from @candidate_pipelines to a variable. With the help of this variable I can access value like variable.attribute. Mainly, I want to access all parameter that are available at the particular index value of the @candidate_pipelines.

kokolegorille

kokolegorille

When You use for, each element of @candidate_pipelines is going to be treated. You don’t need to lookup with an index, because it should be the current element.

Or did I miss something?

ycv005

ycv005 OP

That’s what I have done- iterating over the enumerable but I want only 1 at a time that is present at a index, don’t want to iterate over list/enumerable.

kokolegorille

kokolegorille

You already get one element at a time with this.

ycv005

ycv005 OP

Yes, You are right but the problem is that I don’t want other values. It is wastage of time, resource and unwanted value are getting as output. For example- I want only 2nd element but it is iterating over the whole due to which extra data from other index are geeting as output which I don’t want.

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews