wktdev

wktdev

I used the Phoenix generator to create a table and the accompanying HTML forms.
The form inputs are input and I want to change one of them to textarea.

The form template the generator gives me is this:

<.simple_form :let={f} for={@changeset} action={@action}>
  <.error :if={@changeset.action}>
    Oops, something went wrong! Please check the errors below.
  </.error>
  <.input field={f[:name]} type="text" label="Name" />
  <.input field={f[:version]} type="text" label="Version" />
  <.input field={f[:owner]} type="text" label="Owner" />
  <.input field={f[:note]} type="text" label="Note" />
  <.input field={f[:developer]} type="text" label="Developer" />
  <.input field={f[:status]} type="text" label="Status" />
  <.input field={f[:url]} type="text" label="Url" />
  <:actions>
    <.button>Save Test bed</.button>
  </:actions>
</.simple_form>

If I try to change one of those inputs to textarea I get an error. Example:


  <.textarea field={f[:note]} type="text" label="Note" />

How do I change them without error?

Showing Posts 1 to 5

benwilson512

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

Hi @wktdev please always provide any errors that you get.

EDIT: Based on my read of the core components you should be doing:

  <.input field={f[:note]} type="textarea" label="Note" />
wktdev

wktdev OP

Thanks, and noted.

7stud

7stud

Can you direct me to where I can read about the core components? I can’t find anything about <.input>. For instance, how are people supposed to know what the various possible values for the type attribute are? “textarea” is not a legal type attribute for an html input element, but it works with the input function.

Also, is there something to create a datetime select, e.g.:

<%= datetime_select f, :ends_at %>

perhaps:

<.datetime >

??

codeanpeace

codeanpeace

Core components are defined in your application code so assuming you’re using the generators, take a look at the inline docs in your core_components.ex file.

https://github.com/phoenixframework/phoenix/blob/f549f935735feee9857df1e4753531754f3668d5/priv/templates/phx.gen.live/core_components.ex#L245-L390

Regarding support for "textarea", it’s added via a custom functionhead:

https://github.com/phoenixframework/phoenix/blob/f549f935735feee9857df1e4753531754f3668d5/priv/templates/phx.gen.live/core_components.ex#L349-L367

From a while back, here’s an example of extending the .input core component to support radio buttons.

7stud

7stud

Okay, I see “core components” mentioned everywhere, but there is nothing in the docs about them. In my Phoenix app, I just found the file:

auction_web/lib/auction_web/components/core_components.ex

That’s where things like <.simple_form> and <.input> come from.

The Phoenix.Component docs should allow me to figure out how the functions in core_components.ex work.

— 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
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
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
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
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews