Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Add label to fields group #230

Open
ClemCornet opened this issue Sep 12, 2021 · 5 comments
Open

Add label to fields group #230

ClemCornet opened this issue Sep 12, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@ClemCornet
Copy link

Hi and thank you for this great library.

I was wondering if it's possible to add labels for fields group ? Or do I have to inject them manually with a plugin ?

[
  {
    model: 'user',
    component: markRaw(SchemaForm),
    label: 'Label for fields group here',
    schema: [ ...fields ],
  },
  { ... }
]

Thanks in advance !

@marina-mosti marina-mosti added the enhancement New feature or request label Sep 13, 2021
@marina-mosti
Copy link
Member

Hi @ClemCornet , SchemaForm is a special component which should really not be used for displaying elements.
This would have to be modified with a plugin I think, or possibly modifying the schema to contain parent elements for the field groups.

This is a very important thing for a11y though, so I will mark it as enhancement so we can figure out a way to better address field sets natively

@ClemCornet
Copy link
Author

Hello @marina-mosti , thank you for your responsiveness and for this future improvement. Meanwhile, I'll try to modify my schema ;)

@pau-santesmasses
Copy link
Contributor

pau-santesmasses commented Sep 20, 2021

+1 for fieldsets or some other type of grouping (perhaps <section>?)

@ClemCornet in case it helps, my current solution is to add a class and display the label via a pseudo element. Not ideal, but it works for now.

Something like:

.section::before {
  content: attr(label);
}

@4KDA
Copy link
Contributor

4KDA commented May 23, 2022

Hey!
@marina-mosti, what do you say if I make it possible to add any elements to the forms. For example div or h3 with some text or just any custom component. This will allow you to split the form as desired, for example, using custom separators or group names. I think this will solve this issue. Can I get a merge?

ex
image

@marina-mosti
Copy link
Member

Just use higher level components that contain your labels and header tags and put them in the schema

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants