get_sanitized_values() Doesn’t Pass Empty Values
-
Using the tutorial at
https://webdevstudios.com/2015/03/30/use-cmb2-to-create-a-new-post-submission-form/
I’m trying to extend it to also edit existing instead of just submitting new.But I’m finding the get_sanitized_values(), which is used to clean $_POST variables, strips out empty fields. So there is no way to blank a field once it’s has data. A simple text field can be set to anything other than empty and be saved, but an empty text field is removed in the sanitized values.
Same with checkboxes. Once any on of them is checked you can never save all of them as unchecked. Problem is definitely at the get_sanitized_values because you can watch the values disappear immediately after the call
$this->log($_POST); $sanitized_values = $cmb->get_sanitized_values( $_POST ); $this->log($sanitized_values);The empty value will be in $_POST and gone in $sanitized_values. Makes it impossible to erase a value.
The topic ‘get_sanitized_values() Doesn’t Pass Empty Values’ is closed to new replies.