material icon indicating copy to clipboard operation
material copied to clipboard

validation errors in md-autocomplete

Open javierpavon2000 opened this issue 11 years ago • 40 comments

I want to configure a md-autocomplete input as required and show a message if not filled, but it's not working

<md-autocomplete name="autocompleteName" ...      >
</md-autocomplete>
<div ng-messages="form.autompleteName.$error">
     <div ng-message="required">This is required!</div>
</div>

if I inspect the formController object for the form, there isn't any object for autocompleteName

any hint? any help? I just want to validate the md-autocomplete following as the same way of the inputs, is it possible?

javierpavon2000 avatar Mar 04 '15 12:03 javierpavon2000

made my own autocomplete component, which links ng-messages into it

hitigon avatar Mar 11 '15 19:03 hitigon

Just, I can do it too, but I would prefer to follow the "standard" way like the others inputs

javierpavon2000 avatar Mar 12 '15 08:03 javierpavon2000

@javierpavon2000 I prefer that too, but the md-autocomplete is inconsistent with md-input, that's I really don't like.

hitigon avatar Mar 12 '15 17:03 hitigon

@hitigon Agreed on it's inconsistency with md-input. Seems like it is currently designed to resemble a md-select instead of a md-input. It looks really odd with other md-input elements around it.

bfelda avatar Mar 16 '15 02:03 bfelda

@hitigon @javierpavon2000 @bfelda I just added a styling option for use in standard forms: f487248a70c9bfd749953e98e3412240112f39a3

I will be adding validation support as well.

robertmesserle avatar Mar 20 '15 17:03 robertmesserle

A demo of the new styles can be seen here: https://material.angularjs.org/#/demo/material.components.autocomplete

robertmesserle avatar Mar 20 '15 17:03 robertmesserle

@robertmesserle awesome job!

hitigon avatar Mar 20 '15 17:03 hitigon

Proposed syntax for ng-messages:

<md-autocomplete md-search-text="searchText" required>
  <md-item-template>...</md-item-template>
  <div ng-messages="searchText.$error">
    <div ng-message="required">This field is required</div>
  </div>
</md-autocomplete>

robertmesserle avatar Mar 25 '15 19:03 robertmesserle

Please, can you make some example with validations ? And what is md-item-template ?

111crb111 avatar Apr 17 '15 13:04 111crb111

+1 for md-autocomplete validation example with md-item-template

datak1d avatar Apr 17 '15 13:04 datak1d

+1 with validation example

ghost avatar Apr 22 '15 06:04 ghost

+1

lillylykho avatar Apr 27 '15 09:04 lillylykho

@robertmesserle This looks great! Thanks for implementing it.

bfelda avatar Apr 28 '15 12:04 bfelda

@bfelda this is going to be solved in 0.9.0?

ghost avatar May 04 '15 07:05 ghost

@gpopovic This is not going to be in 0.9.0, but I submitted a Pull Request for this feature: https://github.com/angular/material/pull/2664

robertmesserle avatar May 04 '15 14:05 robertmesserle

:+1:

bopm avatar May 27 '15 17:05 bopm

+1

fabiusss avatar Jun 01 '15 09:06 fabiusss

At master, still no validation for md-autocomplete. The example doesn't work.

pencilcheck avatar Jun 20 '15 04:06 pencilcheck

Opened a new issue for this bug since it still appears to be broken: #3401

MetalHexx avatar Jun 22 '15 20:06 MetalHexx

Yes that's it. It's not working for md-autocomplete validation: screen shot 2015-06-22 at 6 02 38 pm screen shot 2015-06-22 at 6 04 52 pm

caok2709 avatar Jun 22 '15 22:06 caok2709