-
Notifications
You must be signed in to change notification settings - Fork 572
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
Allow for optional/empty money field. #577
Conversation
dfafe1d
to
dc9d625
Compare
The number formatting of field of the text_money type caused a money field to *always* be saved. If the field was empty, it would be saved as '0.00'. This fix allows for the proper (non-)saving of empty money fields.
dc9d625
to
2167d89
Compare
This issue seems not to be solved yet for the cmb2-rest-api branch, I'm still getting money field being saved even if it is empty causing it to have a '0.00' value. |
Did you test with this branch or with the trunk / master branch ? This PR (unfortunately) has not been merged in yet. |
Just saw this. Thanks! |
Hey, @jrfnl. I did actually tested with this branch, which by the way seems not to expose CMB2 custom fields to the WP Rest API either. Maybe I am misunderstanding the way the CMB2 branches work. I've forked the cmb2-rest-api branch and updated my custom post type and cmb2 fields in order to expose it to the WP Rest API v2, as long as I thought it would have all the goods from the master branch + the WP API support. |
I've not worked with the The only thing I can say about it, is that by the looks of it the |
@jrfnl oh, I got it, thanks for the input. So I think it's a matter of waiting for those branches to get merged. The fact is the cmb2-rest-api branch is not working as it should yet, it does not expose my fields to the WP API, so I'm thinking about going back to the master or the trunk branch for the meantime. If at least I could get the API functionality at my disposal, then the saved '0.00' value for the empty text_money field is a thing I could live with. |
The cmb2-rest-api branch is still in-progress, and as such, documentation is sparse. The fields showing in the REST API is an opt-in feature, not opt-out, so you wouldn't see anything by default. Just search for |
Hey @jsternberg. Thanks for pointing out the file, I've already followed all the necessary steps to make it work but no success. I'll try the trunk branch to see if it keeps up with all my cmb2 plugins while solves the WP Rest API not exposing the fields issue. |
@jtsternberg I think the above message was meant for you. |
The number formatting of fields of the text_money type caused a money field to always be saved.
If the field was empty, it would be saved as '0.00'.
This fix allows for the proper (non-)saving of empty money fields.