docs-bug(MatInput): How to nest / wrap material form controls
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
Description
#### Documentation Feedback
I find myself getting stuck on this again and again, and I've been using angular and material since it's inception, so by now it should have stuck up there in the old noggin, but alas.
Today we have a basic tutorial on how to do a completely custom form field
https://material.angular.io/guide/creating-a-custom-form-field-control
but there is no tutorials examples of how to take an existing matInput mat-select or other form controls and wrap them into a component.
Usually we need to do this to DRY things up and not have to have the same error messages, options or reoccurring fields multiple times.
## These are some tutorials / examples I would like to see
**Custom component to wrap sub field names, validation and errors**
I have an Address FormGroup which contains
street, zipcode, city
and a couple of mat-form-fields with labels, inputs, errors
I now want to wrap this into a ``
**Custom `mat-select` with static list of values and validation**
I have a Language select that is reused in multiple places
I now want to use it ``
**Custom `input with some kind of dialog picker`**
A User picker, should display the user name when done, and an icon to the right much like a date picker.
but then in the dialog we have some custom logic to list all users, and the value that comes out of the picker should be the database id for the user.
``
## The struggles
Since matInput already implements ControlValueAccessor it must be possible to just provide / delegate functionality down to that child, but how?
I have multiple implementations of the above, but all of them feel over complicated, or the dirty state isn't working because of something.
We need best practices for creating wrapped form controls and form groups :)
Please let me know if you need more context or examples, I have plenty
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par le guide Angular Material lié sur la création d’un contrôle de champ de formulaire personnalisé et comparez-le aux exemples demandés de contrôles matInput, mat-select, form-group et picker enveloppés. Définissez le périmètre et les modèles recommandés avant d’ajouter des tutoriels ; le travail est terminé lorsque la documentation explique les contrôles et les groupes enveloppés avec des exemples complets, la validation et le comportement de l’état du formulaire.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 28/100