pwt.datepicker icon indicating copy to clipboard operation
pwt.datepicker copied to clipboard

No initial for empty values

Open puraminy opened this issue 2 years ago • 1 comments

Thanks for your great job. Maybe I don't know how to use it. I want the field be empty on new form (inserting something) because there is no date selected, but it should have initial value or convert the input value to Persian when there is a value in the form (Editing a saved form).

This is a logical behaviour, however I don't know how to setup it. Also I don't want to use altField because my forms are created by code and there is one input for each field (corresponded to data model)

puraminy avatar Jun 14 '22 19:06 puraminy

I achived my desired behaviour like this:

if unix = 0 it doesn't set any value (before it set it to current date which is not expected)

    value: function update(unix) {
            if (this.model.options.initialValue == false && this._firstUpdate) {
                this._firstUpdate = false;
            } else if (unix) {
                this._updateInputField(unix);
                this._updateAltField(unix);
            }

And in getOnInitState

...
   if (garegurianDate && garegurianDate != 'undefined') {
                    this.initialUnix = garegurianDate;
                } else {
                    this.initialUnix = 0 //new Date().valueOf();
                }
            }

The code is clean and tracing and changing was easy.

puraminy avatar Jun 14 '22 19:06 puraminy