Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No initial for empty values #399

Open
puraminy opened this issue Jun 14, 2022 · 1 comment
Open

No initial for empty values #399

puraminy opened this issue Jun 14, 2022 · 1 comment

Comments

@puraminy
Copy link

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

puraminy commented Jun 14, 2022

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.

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

No branches or pull requests

1 participant