Ngx-formly: Formly Material - Validation error message doesn't seem to show

Created on 19 Mar 2018  路  4Comments  路  Source: ngx-formly/ngx-formly

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request

Current behavior

When configuring formly as follows:

{
  key: 'name',
  type: 'input',
  templateOptions: {
    label: 'Name (required)',
    required: true
  }
}

..the form is properly invalidated, but the error message doesn't display. I'm using Angular Material here.

Expected behavior

The validation message shows 馃槈

Minimal reproduction of the problem with instructions

https://stackblitz.com/edit/angular-formly-material-vaidation-msg?file=app%2Fform-field-overview-example.ts

question

Most helpful comment

no worry :smile: , a bunch of examples that cover all validation possibilities :) are there:

selection_124

All 4 comments

you have missed one small step, the error message should be defined in NgModule declaration:

    FormlyModule.forRoot({
      validationMessages: [
        { name: 'required', message: 'This field is required' },
      ],
    }),

@aitboudad Oh, I thought those are built-in, as I didn't find them in the demo examples: https://formly.dev/examples/validation/built-in-validations

Oh, stupid me...it's in the FormlyModule.forRoot 馃檮

sorry 馃槗

no worry :smile: , a bunch of examples that cover all validation possibilities :) are there:

selection_124

Was this page helpful?
0 / 5 - 0 ratings