Skip to content

Error: mat-form-field must contain a MatFormFieldControl. #5

@vitorpadilha

Description

@vitorpadilha

This error appear

package.json

...
"@ngxmc/file-input": "^18.0.0",
...

HTML

... folder Campo é obrigatório

...

JS

import { MaxSizeValidator, NgxMatFileInputComponent } from '@ngxmc/file-input';
....
@component({
selector: "app-material-cadastrar-listar-component",
templateUrl: "./cadastrar-editar.component.html",
styleUrls: ["./cadastrar-editar.component.scss"],
imports: [
CommonModule,
MatButtonModule,
MatToolbarModule,
MatExpansionModule,
MatRadioModule,
MatInputModule,
FormsModule,
MatFormFieldModule,
ScrollingModule,
ReactiveFormsModule,
NgxMatFileInputComponent,
CrudGenericoDropdownComponent,
MatAutocompleteModule,
MatTabsModule,
MatIconModule,
NgxEditorModule
],
standalone: true
})

...
ngOnInit() {

    this.editor = new Editor();
    this.configurarFormGroup(this.material);
    this.formGroup.controls["arquivoURL"].valueChanges.subscribe((file: any) => {
       
        this.arquivoURL = file;
        this.material.arquivoURL = this.arquivoURL;
        this.formGroup.patchValue({ arquivoURL: this.arquivoURL });
      
    })
    this.cdr.detectChanges();
    this.selecionado = false;
}

configurarFormGroup(material: Material) {
this.formGroup = this.formBuilder.group(configurarFormGroupPadrao(material));

    if (material && material.id) {
        this.formGroup.addControl("id", new UntypedFormControl(material.id, Validators.required));
        this.formGroup.addControl("arquivoURL", new UntypedFormControl(material.arquivoURL,  [
            Validators.required,
            MaxSizeValidator(this.maxSize * 1024)
          ]));
    }
}

Can someone Help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions