Hello Team
I’m encountering an issue with the
In my Storybook story, I’m using this component with a
I’m encountering an issue with the
kendo-formfield
component when used within my custom wrapper component, FormFieldComponent
. Even though I am passing a single form control with formControlName
, the component keeps throwing the following error:Error: The `kendo-formfield` component should contain only one control of type NgControl with a formControlName or an ngModel binding.
My Setup:
I’ve created a custom wrapper component, FormFieldComponent
, which looks like this:
import { Component, Input, ViewEncapsulation } from '@angular/core';
import { CommonModule } from '@angular/common';
import { InputsModule, Orientation, ShowOptions } from '@progress/kendo-angular-inputs';
@Component({
selector: 'mnp-form-field',
standalone: true,
imports: [CommonModule, InputsModule],
encapsulation: ViewEncapsulation.None,
template: `
<kendo-formfield [orientation]="orientation!" [showErrors]="showErrors!" [showHints]="showHints!">
<ng-content></ng-content>
</kendo-formfield>
`,
styleUrl: './form-field.component.scss',
})
export class FormFieldComponent {
@Input() orientation?: Orientation;
@Input() showErrors?: ShowOptions;
@Input() showHints?: ShowOptions;
}
ReactiveFormsModule
setup. Here’s the story code:export const EmailFieldWithFormGroup: Story = {
render: () => {
const formBuilder = new FormBuilder();
const emailForm: FormGroup = formBuilder.group({
email: ['', [Validators.required, Validators.email]],
});
return {
props: {
emailForm,
emailControl: emailForm.get('email'),
onSubmit: () => {
if (emailForm.valid) {
console.log('Form submitted:', emailForm.value);
} else {
console.error('Form is invalid');
}
},
},
template: `
<form [formGroup]="emailForm" (ngSubmit)="onSubmit()">
<fieldset>
<legend>Email Field</legend>
<mnp-form-field>
<mnp-label [for]="'email'" text="Email"></mnp-label>
<mnp-textbox formControlName="email"></mnp-textbox>
<mnp-form-hint>Enter your email address</mnp-form-hint>
<mnp-form-error *ngIf="emailForm.controls['email'].invalid && emailForm.controls['email'].touched">
Error: Please provide a valid email address.
</mnp-form-error>
</mnp-form-field>
</fieldset>
</form>
`,
};
},
};