wp-shortcake / shortcake

Shortcake makes using WordPress shortcodes a piece of cake.
GNU General Public License v2.0
665 stars 143 forks source link

Avoid saving "null" values on empty select2 fields #763

Closed goldenapples closed 6 years ago

goldenapples commented 6 years ago

We're coercing the value of select2 fields to a string, in order to handle some edge cases in post and term select fields with multiple=true.

However, after deleting all values from a multiple select field which had been previously updated with one or more values, that attribute's value is null.

We don't want to coerce this empty value to the string "null". This PR fixes the issue by replacing null attribute values with the empty string, which doesn't get saved when the model is run through Shortcode.formatShortcode().

Fixes #758.

goldenapples commented 6 years ago

Can I get a review of this bugfix for the next release?

goldenapples commented 6 years ago

Thanks! Merging this now, will get ready to cut a release once #746 is in.