This angular library is built to facilitate the creation of forms, particularly when integrating them with a Dynamics365 backend. The components in this package are built to read the metadata from the Dynamics environment and will correctly assign the lab
npm install @crmdynamicslimited/dynamic-formsFormSection component and provide a Field configuration array.
HTML
`
example.component.ts
`ts
FormGroup: FormGroup = new FormGroup({});
Config: IFieldConfig[] = [
new TextField('textfield', 'Text Field', [Validators.required, Validators.minLength(6)]),
new CheckBox('checkbox', 'Checkbox', Validators.requiredTrue),
new DropDown('dropdown', 'Drop Down', [
{ Value: 1, Label: '1' },
{ Value: 2, Label: '2' },
{ Value: 3, Label: '3' },
]),
];
`
Example overriding the field label when using dynamics linked controls. _attributeMetadata_ is of type Attribute, usually retrieved by the web api or application backend.
`ts
FormGroup: FormGroup = new FormGroup({});
Config: IFieldConfig[] = [
new DynamicsTextField(attributeMetadata, [Validators.required, Validators.minLength(6)], "value", "Custom label"),
new DynamicsDropDown(attributeMetadata, [], value, "Custom label"),
];
`
Usage of number field and currency controls
`ts
FormGroup: FormGroup = new FormGroup({});
Config: IFieldConfig[] = [
new NumberField('integer', 'Integer', [], 10),
new NumberField('decimal', 'Decimal', [], 10, 3),
new NumberField('money', 'Money', [], 10, 2, '$'),
new DynamicsNumberField(this.numberAttribute, null, 1),
new DynamicsNumberField(this.numberAttribute, null, 1, 'Label', '$'),
];
``