roganjoshua
I am trying to get a basic for to do my bidding.
I am very much a beginnner so many things are a bit cloudy.
I have a heex template below:
<main class="px-4 py-20 sm:px-6 lg:px-8">
<.form for={@form} phx-change="validate" phx-submit="Go">
<div class="p-2">
<div>
<.input
name="version"
field={@form[:version_id]}
options={@versions}
type="select"
phx-change="select-version"
value=""
label="Select a Version"
/>
</div>
<div>
<.input
name="customer"
field={@form[:customer_id]}
options={[]}
type="select"
phx-change="select-customer"
value=""
label="Select a Customer:"
/>
</div>
<div>
<.button>
Go
</.button>
</div>
</div>
</.form>
<pre><%= inspect assigns, pretty: true %></pre>
</main>
There are two <selects one is dependent on the other.
So the value selected from versions will populate the other selector with a list of customers that belong to that version.
The related code looks like this at the moment.
defmodule CustomerbuilderWeb.MainLive.Index do
use CustomerbuilderWeb, :live_view
alias Customerbuilder.Builder
@impl true
def mount(_params, _session, socket) do
{:ok,
socket
|> assign(:versions, get_versions())
|> clear_form()}
end
@impl true
def handle_event("select-version", %{"id" => id}, socket) do
{:noreply, stream(socket, :version_collection, id)}
end
@impl true
def handle_event("select-customer", %{"id" => id}, socket) do
{:noreply, stream(socket, :version_collection, id)}
end
def assign_form(socket, changeset) do
assign(socket, :form, to_form(changeset))
end
def clear_form(socket) do
form =
socket.assigns
|> to_form()
assign(socket, :form, form)
end
defp get_versions() do
for version <- Builder.list_version(), do: {version.name, version.id}
end
end
Once the version and customer is set the Go button will take those values and send a POST request to an api (using HTTPPoison?) to kick off a build.
Then a kind of polling to api monitor the progress of the build to update the UI, which I haven’t even started.
a map with atom keys was given to a form. Maps are always considered parameters and therefore must have string keys, got: %{versions: [{"Version-8.6.2",1}, {"Version-8.6.1", 2}, {"Version-8.5.3", 3},
I am very grateful for any interest here.
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
LionelHutz
Looks interesting! Thanks for sharing. Just to confirm - are you looking for advice/insight on how to get to the functionality describe starting from the above, or saying that there’s a more particular problem with how it should already be working?
Thanks.
roganjoshua
I am trying to get any of it working… it is really understanding exactly how it all hangs together.
mount : this is like a init for the live view and you can add models? to the socket for transfer across the websocket
I have added an array of key/value pairs (which I get t from the db) to the versions variable for use by the template. and then send it to a form was a schemaless changeset.
I expect the handle_event for select-version to do something which it really doesn’t at the moment but would do something like
and assign that to the socket for the customer <.select
It is the form bit I am unsure of
not sure how to set this or retrieve it for example
codeanpeace
The data set as assigns and/or streams in the server side socket isn’t transfered across the websocket. It’s the rendered HTML template and subsequent changes/diffs that get sent to the client side via the websocket.
https://github.com/codeanpeace/live_cal/commit/300d7843a31f28a31678db0cf3dd81722656bec8
roganjoshua
Appreciate the time and effort you have put in here @codeanpeace .
It really helps to see examples like this as I can piece together how it works by connecting the names of things.