You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
... 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?
Yeah, I think the built-in inputs could do that. Just not sure if it should be the default behavior. Would there be any side effect on always doing that?
You associate an input with a form by either putting it in the form or setting the form attribute. Forms can't be nested but this is how we can get around that, i.e. allowing us to intermingle different parts of forms on a page or place inputs for a form anywhere we like on the page. With this proposed change, the input would have the form attribute set if either the user has nested the input inside a form (usual way of doing things) and given that form an id, or the user has put the form into the Context themselves. Either way, the input will be associated with the form that they expect, I expect.
MDN on the form attribute of an input:
A string specifying the <form> element with which the input is associated (that is, its form owner). This string's value, if present, must match the id of a <form> element in the same document. If this attribute isn't specified, the <input> element is associated with the nearest containing form, if any.
The form attribute lets you place an input anywhere in the document but have it included with a form elsewhere in the document.
Note: An input can only be associated with one form.
When you're creating forms and associating inputs with them by using the
form
attribute like so... you need to get the
form
from theContext
and setopts={form: form.id}
. It would be nice if the input components set theform
attribute if the form has anid
such that the below could use theIdealFormsComponent
. Would you consider a PR that added this? Or should I be asking the question onphoenix_html
?The text was updated successfully, but these errors were encountered: