Primeng: Calendar should allow valid blank/null value

Created on 7 Apr 2017  路  7Comments  路  Source: primefaces/primeng

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

[x] bug report => Search github for a similar issue or PR before submitting

Plunkr Case (Bug Reports)
http://plnkr.co/edit/sDos4A?p=preview

Current behavior
A date control will remain invalid with errors: {invalidDate: true} when the input value is changed from a value to null.

This may have been introduced with the fix for issue #1676

Expected behavior
By default, a date control should have no validation errors when its value is null.

Minimal reproduction of the problem with instructions
See plunkr above. Steps:

  1. Enter a value into the Date/Time (calendar) field
  2. Delete the value from the field
  3. The formControl still has errors: invalidDate: true

What is the motivation / use case for changing the behavior?
If a null value is always invalid then it seems to be impossible to have a calendar control that is optional on a given FormGroup.

Please tell us about your environment:
MacOS Sierra 10.12.3

  • Angular version: 2.2.1

  • PrimeNG version: 2.0.0 to 2.0.5

  • Browser: Chrome Version 57.0.2987.133 (64-bit)

  • Language: TypeScript 2.0.6

  • Node (for AoT issues): n/a

defect

All 7 comments

Bug still exists in version >4.

Is there any solutions?

Any solution? I have one case for a non required date field which after writing and deleting the value, the entire form becomes invalid exposing this error object

{ "invalidDate": true }

Will review for 4.1.0 final.

How to allow p-calendar to display only years. I didn't found any property for this. could you please help me in this.

@nagpvn2 p-calendar doesn't have functionality to show only years.

I'd recommend using a dropdown or slider or autocomplete with options defined corresponding to your expected year range.

v7.1.0 p-calendar does not emit change even when using formControlName and leave null value. It does appear to be blank on the input, but never trigger valueChanges in the formControl. Any idea?
image
It does trigger on valid value though...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pchristou picture pchristou  路  3Comments

garethlewis picture garethlewis  路  3Comments

just-paja picture just-paja  路  3Comments

watalberto picture watalberto  路  3Comments

miresk picture miresk  路  3Comments