question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DateTime doesn't allow adding Picker buttons or Clearing Value

See original GitHub issue

I’m trying to utilize the DateTime component, but need a way to allow the user to “clear” the field (i.e. remove the value). The DateTime API docs mention that you can pass in the pickerOptions, but when I try to pass in an array of buttons, I see that they’re overwritten with the default Done/Cancel butttons

You can see in datetime.ts that the buttons property is overwritten during instantiation, just after it was merged with the pickerOptions that were sent in.

Is there a suggested approach for removing the value from one of these DateTime controls?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
brandyscarneycommented, Oct 23, 2017

@Simpler1 The handler function was not being copied/called using our deepCopy. This change makes it so you can pass a handler function to the picker, for example:

<ion-datetime pickerFormat="YYYY-MM-DDThh:mm" [pickerOptions]="customOptions" [(ngModel)]="placeholderDate" placeholder="Select Date"></ion-datetime>

customOptions: any = {
  buttons: [{
    text: 'Save',
    handler: () => console.log('Clicked Save!')
  }, {
    text: 'Clear',
    handler: () => {
      this.placeholderDate = null;
    }
  }]
};
2reactions
brandyscarneycommented, Nov 8, 2017

@IshaqBhojaniGenetech Thank you! I pushed a fix for this and released a nightly:

npm install --save --save-exact ionic-angular@3.8.0-201711081800

We plan on releasing a 3.9.1 with this fix in. Please let me know if you are still experiencing problems, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Clear the value in a datetimepicker field - javascript
All I need to do - is - When a button on the screen is clicked, clear some of the input field on...
Read more >
Issue in resetting or clearing the Datepicker | OutSystems
Hi Pankaj, To clear the input date, drag the client action DatePickerClearInputDate and set the InputId property to the Id of the input...
Read more >
Solved: Clear date value - Power Platform Community
Hi,. I have a date field with datepicker in the edit form. I can clear the datepicker but when I clicked submit, the...
Read more >
ion-datetime - Ionic Framework
This component displays buttons which show the current date and time values. When the buttons are tapped, the date or time pickers open...
Read more >
<input type="month"> - HTML: HyperText Markup Language
By default, <input type="month"> does not apply any validation to entered values. The UI implementations generally don't let you enter ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found