question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What

Need to consider a formless usage of field components.

Why

Right now when a field component is rendered and is unable to find any ancestor Form, it will throw an error during the record registration. This may be confusing for the beginning developers.

However, it is also reasonable to insist to wrap fields in Form. Fields compose a form, so there must be a form. This suggestion requires discussion.

Specification

  1. General statements. a) A field is considered formless when it doesn’t have a wrapping <Form> component.
  2. Technical statements. a) A formless field cannot access fields and form within any callback/handler methods. b) A formless field cannot access fields and form in any validation resolvers. c) A formless field behaves as a plain input field. That implies, it is uncontrolled by default, and can be made controlled by providing a value prop and a change handler function. d) (???) A formless field can still accept field enhancers. e) A formless field doesn’t benefit from any form behaviors (serialization, validation, etc.).

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
kettanaitocommented, Feb 12, 2019

Hi, @nickensoul. Thanks for the kind words! Let me update you.

Technical background

The biggest task here is to replace the Form as the event source hub. At the moment the Form component establishes per-instance event emitter, and subscribes to certain events with handlers. Field component wrapped in createField communicates back to the parent Form via form’s event emitter to propagate such events as mounting/unmounting, value change, focus, or blur.

I would say that from the technical perspective a solution to support formless fields is somewhat clear. It would be good to implement (or prepare for) formless fields under #324. I’m currently working on #354, which improves event handlers that would grant less control to the Form, and more to the events.

What now?

I understand both a desire to use a form element without a wrapping Form, and a conceptual idea behind a form input (to gather data for a form). Nevertheless, I still think that formless fields is worth implementing, but I would also encourage developers to expect less functionality from a formless field.

This implementation is on the roadmap, but I would put #324 and #232 as the highest priority.

Functionality limitations

  • A formless field cannot be submitted (that contradicts both forms design and internal implementation)
  • A formless field would require to inherit validation schema and messages from the FormProvider, or via custom HOC (to be discussed)
  • A formless field cannot have reactive props, as they reference fields under a single form domain
2reactions
kettanaitocommented, Apr 27, 2018

Update

It has just occurred to me, that it is possible to understand whether the field is formless on the createField high-order component level.

That way, in case of formless fields, HOC could act as a field’s state accumulator, a replacement for Form in terms of field-form communication. This way field component remains as is, it keeps communicating up as is, as if there is always a form. Instead, createField HOC gets smarter in case of formless fields.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Formless Field of Benefaction - Tricycle
While Buddhist history is steeped in monasticism, our own democratic traditions compel us to share the burden of social problems. The challenge now...
Read more >
purescript-halogen-formless
Formless is a renderless component to help you build forms in Halogen. This module re-exports all ... Validate all fields in the form,...
Read more >
A Formless Field of Benefaction - Zen Mountain Monastery
A formless field of benefaction. ​I wear the Tathagatha's teaching. Saving all sentient beings. Referencing the words of Master Dogen, Shugen Roshi ...
Read more >
Formless designs, themes, templates and ... - Dribbble
Discover 8 Formless designs on Dribbble. ... Formless Arts formless geometry line logo motion ... Formless Fields logo blog design logo.
Read more >
Ahead, the formless field by Mary-Kim Arnold - Tupelo Quarterly
Ahead, the formless field by Mary-Kim Arnold. November 14, 2020 in Collaborative and Cross-Disciplinary Texts tagged Mary-Kim Arnold by Kristina Marie ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found