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

Form validation issue with 1.7.6 #16824

Closed
1 of 3 tasks
PalmerEldritch123 opened this issue Jan 30, 2019 · 5 comments
Closed
1 of 3 tasks

Form validation issue with 1.7.6 #16824

PalmerEldritch123 opened this issue Jan 30, 2019 · 5 comments

Comments

@PalmerEldritch123
Copy link

I'm submitting a ...

  • bug report
  • feature request
  • other

Current behavior:

I have a form with 2 fields (one input and one textarea, input is required, and textarea is not). On 1.7.6 when I display page with that form the textarea is marked as required (if I focus on it and then click outside the error message is displayed). After entering any text the error is gone, and textarea is no longer required (I can clear any text and no error is shown). With 1.7.5 and below this works as expected.

Here is the form object when page is rendered on 1.7.5:

{
  "$error": {
    "required": [
      {
        "$validators": {},
        "$asyncValidators": {},
        "$parsers": [],
        "$formatters": [
          null
        ],
        "$viewChangeListeners": [],
        "$untouched": true,
        "$touched": false,
        "$pristine": true,
        "$dirty": false,
        "$valid": false,
        "$invalid": true,
        "$error": {
          "required": true
        },
        "$name": "username",
        "$options": {}
      }
    ]
  },
  "$name": "userForm",
  "$dirty": false,
  "$pristine": true,
  "$valid": false,
  "$invalid": true,
  "$submitted": false,
  "username": {
    "$validators": {},
    "$asyncValidators": {},
    "$parsers": [],
    "$formatters": [
      null
    ],
    "$viewChangeListeners": [],
    "$untouched": true,
    "$touched": false,
    "$pristine": true,
    "$dirty": false,
    "$valid": false,
    "$invalid": true,
    "$error": {
      "required": true
    },
    "$name": "username",
    "$options": {}
  },
  "description": {
    "$validators": {},
    "$asyncValidators": {},
    "$parsers": [],
    "$formatters": [
      null
    ],
    "$viewChangeListeners": [],
    "$untouched": true,
    "$touched": false,
    "$pristine": true,
    "$dirty": false,
    "$valid": true,
    "$invalid": false,
    "$error": {},
    "$name": "description",
    "$options": {}
  }
}

Below the same page but with 1.7.6:

{
  "$error": {
    "required": [
      {
        "$validators": {},
        "$asyncValidators": {},
        "$parsers": [],
        "$formatters": [
          null
        ],
        "$viewChangeListeners": [],
        "$untouched": true,
        "$touched": false,
        "$pristine": true,
        "$dirty": false,
        "$valid": false,
        "$invalid": true,
        "$error": {
          "required": true
        },
        "$name": "username",
        "$options": {}
      },
      {
        "$validators": {},
        "$asyncValidators": {},
        "$parsers": [],
        "$formatters": [
          null
        ],
        "$viewChangeListeners": [],
        "$untouched": true,
        "$touched": false,
        "$pristine": true,
        "$dirty": false,
        "$valid": false,
        "$invalid": true,
        "$error": {
          "required": true
        },
        "$name": "description",
        "$options": {}
      }
    ]
  },
  "$name": "userForm",
  "$dirty": false,
  "$pristine": true,
  "$valid": false,
  "$invalid": true,
  "$submitted": false,
  "username": {
    "$validators": {},
    "$asyncValidators": {},
    "$parsers": [],
    "$formatters": [
      null
    ],
    "$viewChangeListeners": [],
    "$untouched": true,
    "$touched": false,
    "$pristine": true,
    "$dirty": false,
    "$valid": false,
    "$invalid": true,
    "$error": {
      "required": true
    },
    "$name": "username",
    "$options": {}
  },
  "description": {
    "$validators": {},
    "$asyncValidators": {},
    "$parsers": [],
    "$formatters": [
      null
    ],
    "$viewChangeListeners": [],
    "$untouched": true,
    "$touched": false,
    "$pristine": true,
    "$dirty": false,
    "$valid": false,
    "$invalid": true,
    "$error": {
      "required": true
    },
    "$name": "description",
    "$options": {}
  }
}

The description field is marked as required with 1.7.6 and not required with 1.7.5.

Expected / new behavior:

The code works the same on 1.7.5 and 1.7.6.

Minimal reproduction of the problem with instructions:

If really needed I can provide some example, but maybe you guys can find the cause without it.

AngularJS version: 1.7.6, snapshot too

Browser: [all | Chrome XX | Firefox XX | Edge XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView | Opera XX ]

Firefox 65

Anything else:

@jniles
Copy link

jniles commented Jan 30, 2019

By any chance, are any of these in a ngRepeat or ngIf? If so, it is probably a manifestation of #16814.

@PalmerEldritch123
Copy link
Author

Yup, this is a dynamic form which is generated by ng-repeat.
I was looking at open issues and didn't find anything related.
So probably this is duplicate and can be closed.

@gkalpak
Copy link
Member

gkalpak commented Jan 30, 2019

If that is the case, the code should work with the current snapshot. @PalmerEldritch123, can you verify that?

@PalmerEldritch123
Copy link
Author

It's OK with current snapshot, I probably messed something up when I was testing it. Sorry for confusion :)

@gkalpak
Copy link
Member

gkalpak commented Jan 30, 2019

Awesome! Thx for following up.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants