Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

validation errors in md-autocomplete #1780

Closed
javierpavon2000 opened this issue Mar 4, 2015 · 40 comments
Closed

validation errors in md-autocomplete #1780

javierpavon2000 opened this issue Mar 4, 2015 · 40 comments
Assignees
Milestone

Comments

@javierpavon2000
Copy link

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?

@hitigon
Copy link

hitigon commented Mar 11, 2015

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

@javierpavon2000
Copy link
Author

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

@hitigon
Copy link

hitigon commented Mar 12, 2015

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

@bfelda
Copy link

bfelda commented Mar 16, 2015

@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.

@robertmesserle
Copy link
Contributor

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

I will be adding validation support as well.

@robertmesserle
Copy link
Contributor

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

@hitigon
Copy link

hitigon commented Mar 20, 2015

@robertmesserle awesome job!

@robertmesserle robertmesserle added needs: team discussion This issue requires a decision from the team before moving forward. type: feature type: enhancement in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs and removed needs: team discussion This issue requires a decision from the team before moving forward. type: feature labels Mar 25, 2015
@robertmesserle
Copy link
Contributor

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 robertmesserle removed the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Mar 31, 2015
@robertmesserle robertmesserle modified the milestones: 0.10.0, 0.9.0 Apr 2, 2015
@111crb111
Copy link

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

@datak1d
Copy link

datak1d commented Apr 17, 2015

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

@gpopovic
Copy link

+1 with validation example

@lillylykho
Copy link

+1

@bfelda
Copy link

bfelda commented Apr 28, 2015

@robertmesserle This looks great! Thanks for implementing it.

@gpopovic
Copy link

gpopovic commented May 4, 2015

@bfelda this is going to be solved in 0.9.0?

@robertmesserle
Copy link
Contributor

@gpopovic This is not going to be in 0.9.0, but I submitted a Pull Request for this feature: #2664

@bopm
Copy link

bopm commented May 27, 2015

👍

1 similar comment
@fabiusss
Copy link

fabiusss commented Jun 1, 2015

+1

@pencilcheck
Copy link

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

pencilcheck referenced this issue Jun 20, 2015
BREAKING CHANGE: `name` attribute has been changed to `input-name` to
more clearly show its purpose

Closes #2808
Closes #2664
@MetalHexx
Copy link

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

@caok2709
Copy link

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
Copy link

Even if you said it's required.... $error will always be empty.

@SergeyBukhman
Copy link

There's a bug with the documentation and example. Instead of 'md-input-name' the documentation says 'name' and the example says 'input-name'.

@MetalHexx
Copy link

@SergeyBukhman - to be clear, "name", "md-input-name", and "input-name" all do not work.

@Luxiyalu
Copy link

md-input-name works as of 0.10.0. Documentation for it is seriously misleading.

@MetalHexx
Copy link

Md-input-name does not work for me. Anyone have a plunk or codepen showing it working?

@deckikwok
Copy link

+1. not working on 0.10.0.

@MetalHexx
Copy link

He's resolving it off issue #3401

@danieladz
Copy link

md-input-name="autocompleteInputName" worked for me, you should attach the error to the input inside de md-autocomplete.
now my problem is that the field is shown in red from the start, because is not $pristine u_u

@evoker
Copy link

evoker commented Aug 5, 2015

This doesn't seem to be working in RC5 for 0.10.1

@chrisguerrero
Copy link
Contributor

+1

md-input-name and required don't work for me either with 0.10.0

My temporary solution was to add a hidden input with the same model as md-selected-item

@alo
Copy link

alo commented Sep 15, 2015

+1

@jibiabraham
Copy link

@MetalHexx md-input-name is the right attribute to use.
Additionally, for usage along with ng-messages (when ng-messages are added within the autocomplete), you need to use floating labels via md-floating-label

@getuliojr
Copy link

I haven´t got this to work and the one that is present in the DEMO page is also not working for the required field. I appreciate if anyone has an idea about it.

@GustavSt
Copy link

Indeed, When seemingly doing everything right, the error message is shown from start, like @danieladz stated

@GustavSt
Copy link

I realized I get more weird behavior when trying to have validations when the md-autocomplete is not inside a form. the example of having validation on the md-autocomplete, and using floating label, it is used inside a form. And they are using the name of the form when using ng-messages eg ng-messages="formName.autoCompleteName.$error". I am not able to get it working with a stand alone md-autocomplete without form.

@91K00
Copy link

91K00 commented Jan 8, 2016

For me it's not working with version 1.0.1, am I the only one ?

http://codepen.io/anon/pen/obWZqP

@Wykks
Copy link

Wykks commented Jan 12, 2016

@91K00
Look at #6393

@ghost
Copy link

ghost commented Mar 23, 2016

not working with version 1.0.6 if write required.
but with required="true" works for me according to #6393.
works with version 1.1.0-rc1.

@ghost
Copy link

ghost commented Apr 25, 2016

It seems, the $dirty state does not work properly. Instead of focussing and unfocussing the input field, you need to type in something and remove it again. This is inconsistent compared to other input fields (and wrong as well). In addition, I have to add a seperate ng-show directive (which is different for default input fields, too).

<div ng-messages="emptyingForm.myInput.$error" ng-show="emptyingForm.myInput.$dirty">
    <div ng-message="required">Error message</div>
</div>

Hans

@ThomasBurleson
Copy link
Contributor

@haenig - please do not comment on closed issues. Please open a new issue.

@angular angular locked and limited conversation to collaborators Apr 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests