Sidi_Mohammed
Hello everybody,
Iam new to Phoenix Components, I have tried form inside LiveView and it was amazing, but I have an issue :
form is created by Phoenix.Component.to_form/2 which transform a changeset to a form and we can use <.input type = "text" field = {@form[:somefield]} to represent a form’s field and the user’s data will be found in handle_event("submit", %{"user" => data}, socket) after submitting the form, Okay that’s fine.
But how about other inputs types than <.input type = "text"> ?
For example if we want to implement a template where someone can Signup a new account :
he has some <.input type = "text">s like username, email, password and he has to choose from a “Radio Button” between Man and Woman and he has to choose a date of birth from “Scroll Lists”…
So how we can implement that ? and the most important how we can retrieve user’s entered data in handle_event("submit"....) ?
I have searched about and I couldn’t find docs or examples, so I will be thankful for your answers.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
codeanpeace
With the new core components like
<.input ...>and<.modal>, they’re just functions that are defined and documented within your Phoenix app inlib/hello_web/components/core_components.ex.https://github.com/phoenixframework/phoenix/blob/f8c0ad26ee031ee87a6e7307f6dc1f7722134dd5/installer/templates/phx_web/components/core_components.ex#L227-L264
So while the
typeattribute defaults to"text", it also accepts a whole bunch of other values including"radio"as well as"date".Sidi_Mohammed
Thank you @codeanpeace,
Considering we have used no-text type for an
<.input>for example “Multi Select List”, how we can retrieve user’s input inhandle_event/3after submitting ?jmnda
Hi @Sidi_Mohammed , kindly asking if you can elaborate more or provide more context on your question, perhaps even a simple example of what you are trying to archieve?
Sidi_Mohammed
@jmnda I gave an example of Signing up
jmnda
Just want to understand what you mean here:
Are you trying to implement a Multi Select input?
Sidi_Mohammed
Exactly @jmnda, I want to implement a list which the user can select multi values, how we can implement that please ? and how we can retrieve the selected values in
handle_event/3when submitting the form ?Joep
Did you search for it on these forums?
https://forum.elixirforum.com/search?q=Multi%20select
jmnda
Use can pass a
multipleattribute to yourinputwithoptionsto select, for example:As @Joep suggested, you can search on the forum, alternatively you can look at this guide, or checkout this library
codeanpeace
Here’s how you can discover it for yourself!
Sidi_Mohammed
I sword I have thinked the same thing to show the data’s
, Iam just waiting until turn on my computer,
mapand see what’s happeningthank you a lot again @codeanpeace