-
Notifications
You must be signed in to change notification settings - Fork 747
Custom form component base #3583
Comments
This is probably related to #2886 |
Yes, this is a duplicate of #2886, but has some useful input to bring into the discussion. I have already done some work on this, but it hasn't been finalized. The challenge is coming up with a pattern that works well for everybody, but some cases might require manual validation (due to not knowing how everybody integrates with built-in validation). |
@gnomeontherun in minimal implementation, it should just generate proper markup, similar to what I put into a workaround example. As for validation - it is pretty straightforward. In ugliest template forms implementation, you might generate some hidden input element, if the real field is hidden inside a modal. In case of a reactive forms, control may reflect validation state of a provided form group. |
I'm going to go ahead and close this as a duplicate since its linked to the actual ticket. There has been some work but I don't have an expected delivery at this stage. Trying to consolidate tickets to help us keep our board focused. |
Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary. |
Summary
While using Clarity to develop forms, I found a pattern, which may deserve to be implemented as a form component, or to be a documented workaround or so.
Often, there is a need to put form component in a modal. It is useful for multiple selection, situations, when you need some rich custom UI to produce resulting value for a form field, etc.
In this case, what you want to display on a form - is a form label, like we have for all stock form elements, and a button instead of input/select/textarea, which will open modal.
Plus, I often put label + produced value below this construction.
And, finally, we may also want to display standard Clarity form field validation error.
New type of a form component, without direct input element, where you can put something else (non-input element) instead of input/select/textarea element and get a proper layout and support for helper/validation messages
If one day you add form-level or global form grid layout settings, it will help to incorporate custom form elements under the umbrella of a common form settings.
Plus, such cases may document obvious and straightforward implementation for such use cases.
It doesn't
Not sure
Use case
Our most common use case is a multiple selection in a modal. Not just because Clarity lacks multiselect component - in many cases multiselect component may not be comfortable and modal will still win in usability.
Examples
Multiselect in a modal, with displaying resulting value
No value selected:
![image 4](https://user-images.githubusercontent.com/32732457/60624655-87f0e700-9dee-11e9-92c3-b3f7be154876.png)
Displaying selected values:
![image 5](https://user-images.githubusercontent.com/32732457/60624659-8a534100-9dee-11e9-96ef-fa4e9732ec49.png)
![image 8](https://user-images.githubusercontent.com/32732457/60624662-8c1d0480-9dee-11e9-9f0d-f79221d3af85.png)
Field with input, which is being displayed on demand
Initial state:
![image 6](https://user-images.githubusercontent.com/32732457/60624753-c686a180-9dee-11e9-9da8-a24ba629cf27.png)
After requesting change:
![image 7](https://user-images.githubusercontent.com/32732457/60624778-db633500-9dee-11e9-9150-2d8efe995b35.png)
We currently don't have examples with the validation, but it shouldn't be hard to imagine helper text and validation message placement.
Workarounds
Currently, we take layout for css input element and put something we want instead of an input field.
The text was updated successfully, but these errors were encountered: