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

Empty form fields are missing from the model obgect #384

Open
AviFix opened this issue Feb 7, 2021 · 9 comments
Open

Empty form fields are missing from the model obgect #384

AviFix opened this issue Feb 7, 2021 · 9 comments

Comments

@AviFix
Copy link
Contributor

AviFix commented Feb 7, 2021

Hi,

When leaving a field empty, its property seems to be removed from the form value.

Regular angular form:
image
firstName is empty but is exist

ngx-schema-form:
image

email is empty and not showing in the model object.

Thanks

@daniele-pecora
Copy link
Collaborator

That is true, but how could it be handled otherwise and maintain the required validation?

@AviFix
Copy link
Contributor Author

AviFix commented Feb 8, 2021

What do you mean?
Does it contradict?

@daniele-pecora
Copy link
Collaborator

daniele-pecora commented Feb 8, 2021

Partially it does, because required wouldn't trigger if field is empty, only triggers if field is not present.

@AviFix
Copy link
Contributor Author

AviFix commented Feb 8, 2021

Isn't it possible to trigger the required if the field is empty like the angular form control does?

@daniele-pecora
Copy link
Collaborator

ngx-schema-form doesn't rely on angular form control validation rather on a json schema validator.
The default validator implementation is Z-Schema.
JSON Schema validation counts an empty property as present and therefore the required rule is passed as 'valid'.
A 'required' validation is negative only if the required property is not present at all.

@AviFix
Copy link
Contributor Author

AviFix commented Feb 9, 2021

Thanks for the detailed explanation.

Could you please point me to the code that is in charge of removing the empty fields and to the validation part?

@daniele-pecora
Copy link
Collaborator

I don't know it myself.
For preventing a huge breaking change this should end in a feature that can optionally be activated.
Maybe via forRoot(...) or smt else

@AviFix
Copy link
Contributor Author

AviFix commented Feb 18, 2021

Sure

Anyone else that can point me toi the code that is in charge of removing the empty fields and to the validation?

@daniele-pecora
Copy link
Collaborator

@AviFix I would guess that widget.ts could be a good start (just guessing)

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

2 participants