-
Notifications
You must be signed in to change notification settings - Fork 748
Generic form containers for non-input elements and for custom Angular components. #2886
Comments
I believe this duplicates #2864 |
Thank you for the well written request, this is useful for helping understand the use cases. As a workaround, you could use the HTML and build the same DOM structure, but there could still be edge cases and some CSS to apply to make things look exactly as you wish. This is definitely something we need to look into handling, but since this one is more detailed I'm going to mark the other as a duplicate and close it in favor of this one. |
Hello, |
@paddyfink No you cannot, because they don't wire up the internals like we do. However, you could use the HTML/CSS version (the bottom part of the documentation for inputs for example) and replace the input with a third party component. There might be some styling issues to address for it to layout properly though. |
Ok Thanks @gnomeontherun. I will give it a try. |
This one is important. Even having a simple container object that doesn't support validation etc would be very useful. |
As far as I can see the other issue hasn't been considered in Clarity 2.0+ either. Anyway, whether it is a custom component or a standard input with extra custom content next to it, I think the use case is quite similar. |
We have a lot of custom components (and also use many signposts), and this is one of the major hurdles for us upgrading to the new forms. |
I've investigated this before, and the custom styling present in many third party components makes this pretty difficult, if not impossible. There is likely to be a manual styling overrides required depending on what the control is and how it displays. We can work on a scaffolding for a starting point, but making it seamless is very unlikely. |
I was able to make custom form controls and was able to make them work as if they are part of the pre-built Clarity forms. I created custom form controls and custom input containers. They respond very nicely with Clarity form's layout services, validations indicators, etc. The workaround is to copy all the required services and utility classes since Clarity doesn't expose these to the public. I just changed the filenames but kept the component/directive selectors unchanged. This allows me to trick Angular as if they are Clarity's. The only drawback that I can currently think of is that I have to keep this in-synced with the original code every time Clarity updates the library. Also, I'm not sure if there are adverse effects of doing this type of workaround. |
whizkidwwe1217, this is interesting and something we would like to use (and need) when some day we switch to the 2.0 forms. |
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
Angular Form Input Controls
Use case
1. Non-input element/static content
There are some fields in a form that don't need an input from the user and the purpose of those fields is just to display read-only or system generated texts. These static contents needs to be laid out properly in the form just like how the labels are aligned and the existing supported input controls are being laid out in the form.
2. Custom components
Right now, only those input controls that have supported input directives like clrInput are supproted by Clarity. Without a directive, the control will not be displayed in the form. I should be able to display a custom component. For example, a rich text editor component.
Examples
Are there any examples in other projects that demonstrate this feature or enhancement?
Non-input components
clr-input-container does not display an Angular component or an HTML element inside it if it doesn't have an input directive.
Example:
or
Tried without clr-input-container but labels and components are not laid out and formatted properly.
Custom components
Workarounds
Is there a workaround for this feature at the moment, even if it is less than ideal?
I'm currently using the Clarity forms for Angular. Maybe a combination of angular & Clarity's css for forms
The text was updated successfully, but these errors were encountered: