-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Proposal] medatdata / extras property for AbstractControl #19686
Comments
Is there any news on this? :) |
Any updates here? |
For those interested, I created a proposal to update In addition to adding a |
It may be achieved by simple extending of FormControl, then each of custom inputs may have its own custom model extending DefaultFormControlModel. However native support for such feature would be highly appreciated. export interface DefaultFormControlModel<T> {
value?: T;
required?: boolean;
label?: string;
disabled?: boolean;
readonly?: boolean;
asyncValidators?: Validator[];
validators?: Validator[];
}
export abstract class CustomFormControl<T extends DefaultFormControlModel<T['value']>> extends FormControl {
public model: T = { } as any;
protected constructor(defaultFormControlModel: T) {
super({
value: defaultFormControlModel.value,
disabled: !!defaultFormControlModel.disabled,
},
getValidators(defaultFormControlModel.validators),
getAsyncValidators(defaultFormControlModel.asyncValidators),
);
Object.assign(this.model, defaultFormControlModel);
}
public setModelProperty(name: string, value: any) {
this.model[name] = value;
}
} |
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends. Find more details about Angular's feature request process in our documentation. |
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage. We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package. You can find more details about the feature request process in our documentation. |
Mata data is a best features when you are creating dynamic reactive forms also where form group is also dynamically created by form controls such as i need to send Mata data can fix this problem very easily while creating Form Control i can set all mata data related to that object with attributeValue and at the end i have my array of object already set Please reconsider this feature and add mata data support |
I just ran into a use case in which I need meta data on AbstractControl, all for the same reasons as other users here on this thread. Additional information for the control would allow us to dynamically create forms, without the need to manually create templates every time we need a form. In the meantime, we'll have to find a way to extend or modify Angular's AbstractControl type. |
I'm submitting a...
Current behavior
Currently there is no way to construct FormControl, FormGroup and FormArray and set metadata / extras info (ex. allowedValues etc.)
Expected behavior
Possibility to set metadata / extras info
What is the motivation / use case for changing the behavior?
Possibility to set metadata info for each specific control would be very helpful when writing forms. For example generating select options would looks like that:
Or if you have a form which is table but not all cells are controls, let say in each row you have cell with id (it is not a control just value for the user):
And there may be many more usage examples
Proposal API
Setting this new property should be possible by using
FormBuilder
,FormControl
,FormGroup
andFormArray
:FormBuilder#group
pass as optional property inextra
argFormBuilder#array
,FormGroup
andFormArray
pass as 4th optional argFormBuilder#control
andFormControl
pass as optional property informState
argExample:
The text was updated successfully, but these errors were encountered: