Sidi_Mohammed

Sidi_Mohammed

Hello,
as RESTful API from resources offers new and create routes to create a new user, I don’t know how to use them,
new will trigger the server to return an HTML form to upload our informations, okay that’s fine, but how we can send those informations back to the server ? and what is the relation with create route ?

Showing Posts 1 to 3

codeanpeace

codeanpeace

GET /users/new HelloWeb.UserController :new

POST /users HelloWeb.UserController :create

source: Routing — Phoenix v1.8.8

The :new route is to get the blank form, hence the GET HTTP request. While the :create route is to submit/post the completed form, hence the POST HTTP request.

If you’re on a relatively new version of Phoenix and ran mix phx.gen.html ..., you’d see a form component with an action that points to a :create route.

<.form :let={f} for={@changeset} action={Routes.comment_path(:create, @comment)}> # or action={~p"/comments"} if using verified routes
  <.input field={f[:body]} />
</.form>
Sidi_Mohammed

Sidi_Mohammed OP

Thann you @codeanpeace for your answer and sorry for the delay,
In fact what I was mistaken about, is that I thinked for a Framework as Regular RESTful API, that means I expected to render a simple html form by calling new and after that sending “manually” the informations to the server and this is not the case for Phoenix.
Iam new to Phoenix and I didn’t use LiveView before, what caught my attention is the link that you gave me which describe the form as “regular http request outside of LiveView” so just if you can tell me or suggest a link of how to do that with LiveView ?

codeanpeace

codeanpeace

Phoenix supports both traditional stateless RESTful HTTP request/response through Phoenix.Controller as well as stateful WebSocket connections through LiveView Phoenix.Liveview.

If I’m understanding you correctly, you can just scroll up using the link above for an example of using the form component within a LiveView or alternatively use this link. You can also use the mix phx.gen.live task to generate functional LiveView example code.

— All posts loaded —

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
kpanic
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
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
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
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews