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

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
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

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews