Set form attribute on inputs when form is given an id
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 42/100
Línea de trabajo
Start by locating the input components and their form Context handling, then inspect how form attributes are currently passed through component options. Done means inputs rendered inside a form with an id automatically receive that id as their form attribute, while existing explicit options continue to work.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When you're creating forms and associating inputs with them by using the form attribute like so
<form id="form-1"></form>
<form id="form-2"></form>
<input type="text" name="form-1-name" form="form-1" />
<input type="text" name="form-2-name" form="form-2" />
... you need to get the form from the Context and set opts={form: form.id}. It would be nice if the input components set the form attribute if the form has an id such that the below could use the IdealFormsComponent. Would you consider a PR that added this? Or should I be asking the question on phoenix_html?
defmodule MyWeb.FormsComponent do
use Surface.Component
alias Surface.Components.Context
alias Surface.Components.Form.{Field, Label, TextInput}
def render(assigns) do
~F"""
<Context get={form: form}>
<Field name={:thing}>
<Label text="Thing" form={form} />
<TextInput form={form} opts={form: form.id} />
</Field>
</Context>
"""
end
end
defmodule MyWeb.FormsComponentNamedspaceContext do
use Surface.Component
alias Surface.Components.Context
alias Surface.Components.Form.{Field, Label, TextInput}
def render(assigns) do
~F"""
<Context get={Surface.Components.Form, form: form}>
<Field name={:thing}>
<Label text="Thing" />
<TextInput opts={form: form.id} />
</Field>
</Context>
"""
end
end
defmodule MyWeb.IdealFormsComponent do
use Surface.Component
alias Surface.Components.Context
alias Surface.Components.Form.{Field, Label, TextInput}
def render(assigns) do
~F"""
<Field name={:thing}>
<Label text="Thing" />
<TextInput />
</Field>
"""
end
end
defmodule MyWeb.FormsLive do
use MyWeb, :surface_live_view
alias MyWeb.FormsComponent
alias MyWeb.FormsComponentNamedspaceContext
alias Surface.Components.Context
@impl true
def mount(_params, _session, socket) do
{:ok,
assign(socket,
thing1: changeset(%{thing: "thing1"}),
thing2: changeset(%{thing: "thing2"})
)}
end
defp changeset(data \\ %{}, params) do
types = %{thing: :string}
Ecto.Changeset.cast({data, types}, params, Map.keys(types))
end
@impl true
def render(assigns) do
~F"""
<main>
{form1 =
form_for(@thing1, "#",
as: :thing1,
id: "thing1form",
phx_change: "change1",
autocomplete: "off"
)}
<#Raw></form></#Raw>
{form2 =
form_for(@thing2, "#",
as: :thing2,
id: "thing2form",
phx_change: "change2",
autocomplete: "off"
)}
<#Raw></form></#Raw>
{!--
<Context put={Surface.Components.Form, form: form1}>
<IdealFormsComponent />
</Context>
--}
<Context put={Surface.Components.Form, form: form1}>
<FormsComponentNamedspaceContext />
</Context>
<Context put={form: form2}>
<FormsComponent />
</Context>
</main>
"""
end
@impl true
def handle_event(event, params, socket) do
IO.inspect([event, params], label: "forms live")
{:noreply, socket}
end
end
- Lenguaje dominante
- Elixir
- Estrellas
- 2.1k
- Forks
- 146
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de surface-ui/surface
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
surface-ui/surface#634 · 1 reacción ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
surface-ui/surface#770 ·
-
Website is downAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
surface-ui/surface#768 · 4 comentarios ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
surface-ui/surface#762 · 2 comentarios · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
surface-ui/surface#759 · 1 reacción ·
Todos los issues de surface-ui/surface
Issues similares
-
bug(dashboard): gate card last-seen badge shows inventory-sync timestamp, not sweep observation timeAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
carverauto/serviceradar#5793 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
intellij-elixir/intellij-elixir#4492 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
expert-lsp/expert#942 ·
Los mantenedores suelen responder en 1 día
-
L: github:actions L: javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
dependabot/dependabot-core#16615 ·
Los mantenedores suelen responder en 1 día
-
Markdown preview can show an outdated version of the cell sourcePosiblemente ocupada @RaphaelFakhri la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
livebook-dev/livebook#3228 ·
Los mantenedores suelen responder en 1 día