venomnert
Context:
I am trying to setup a simple liveview form.
Help:
When I visit the form /client/new and submit an entry, phx_submit event doesn’t get triggered. It instead makes a post request to /client/new which doesn’t exist.
lib/contact_us_web/live/client_live/index.ex
defmodule ContactUsWeb.ClientLive.Index do
use Phoenix.LiveView
alias ContactUsWeb.Router.Helpers, as: Routes
alias ContactUsWeb.ClientView
alias ContactUs.Accounts
alias ContactUs.Accounts.Client
def mount(_session, socket) do
changeset = Accounts.change_client(%Client{})
{:ok, assign(socket, :changeset, changeset)}
end
def render(assigns) do
Phoenix.View.render(ClientView, "form.html", assigns)
end
def handle_event("save", args, socket) do
IO.inspect(args, label: "VALDIATE DATA")
{:noreply, socket}
end
end
lib/contact_us_web/templates/client/form.html.leex
<%= form_for @changeset, "#", [phx_submit: "save"], fn f -> %>
<%= label f, :first_name %>
<%= text_input f, :first_name %>
<%= error_tag f, :first_name %>
<%= label f, :last_name %>
<%= text_input f, :last_name %>
<%= error_tag f, :last_name %>
<%= label f, :email_address %>
<%= text_input f, :email_address %>
<%= error_tag f, :email_address %>
<%= label f, :phone_number %>
<%= text_input f, :phone_number %>
<%= error_tag f, :phone_number %>
<%= label f, :company %>
<%= text_input f, :company %>
<%= error_tag f, :company %>
<%= label f, :service %>
<%= text_input f, :service %>
<%= error_tag f, :service %>
<div>
<%= submit "Save", phx_disable_with: "Saving..." %>
</div>
<% end %>
I made sure everything is setup properly. However, I’m unable to determine what the issue is.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
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
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #security
- #elixirconf-eu
- #api
- #forms
- #performance











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
mindok
Hi @venomnert,
Have you verified that your liveview is mounting correctly? Put an
IO.inspectin themount(you should see the message twice - once for the initial render and once when the websocket connection is made) andrenderfunctions. If it itsn’t, then double-check your router setup.Also, do you have any other liveview functionality behaving properly in the application? You may have issues with javascript library versions etc…
venomnert
Hey @mindok,
I have tried adding ‘connect?(socket)’ inside of my mount function and it always returns false
mindok
Just heading out so answer will be brief… try a different browser, and recheck installation and JavaScript wire up instructions…
venomnert
Hey @mindok,
I have tried the following:
deps/phoenix_live_view/guides/introduction/installation.mdsocket "/live", Phoenix.LiveView.Socket, websocket: [connect_info: [session: @session_options]]causes some error, so i have ignored.I’m still getting the same results.
BTW I do want to say thank you for helping me out.
mindok
OK - that bit that is causing you errors is important - it is how the browser and liveview server communicate.
What if you just try
socket "/live", Phoenix.LiveView.Socket, websocket: trueor even just
socket "/live", Phoenix.LiveView.Socketas per https://hexdocs.pm/phoenix_live_view/installation.html#content
If those don’t work, post the error messages
venomnert
Hey @mindok I have tried what you have suggested, but still no luck. BTW here it code I used to check connection status:
mindok
Ok, a few more things:
IO.inspectcall? (i.e. do you get one false, and then one true result?)e.g.
venomnert
Are there any error messages in the console running the application?
A: No error message
What are the results from your
IO.inspectcall? (i.e. do you get one false, and then one true result?)A: Here is the log I get when I do inspect
A: Yep, copied from the installation guide
A: No console log error.
What i’m thinking of doing next is a fresh install of liveview.
mindok
Yep - something isn’t right. You should see your
connected?return true. See if you can find a working liveview sample project on github to clone from - the master liveview sample project is a bit out of date with versions, but this one uses the latest version: GitHub - pthompson/live_component_examples · GitHubmindok
One more thing…
Check that your app.js is getting executed. Put something like
console.log(“hello it’s working”);just before the liveview connection code
Open your page and check the browser console for your message. If you don’t see it you know what you need to fix…