Text field value doesn’t update immediately based on sanitize_cb
-
Good morning everyone. I have a text field with the follow sanitization_cb for the post post type.
function validateWordField($value, $field_args, $field) { $words = explode(' ', trim($value)); if (count($words) > 0) { $sanitized_value = sanitize_text_field($words[0]); } else { $sanitized_value = sanitize_text_field($value); } return $sanitized_value; }
If I digit in the field “abc xyz” and than save the post, the sanitization callback remove ” xyz” but in the field appears “abc xyz” yet.
If I reload the page (right click and Reload Page), in the field appears “abc xyz” again.
If I go away from the post screen and then I come back, now the value is “abc”.
There is a way to show the sanitized value immediately after the post save?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Text field value doesn’t update immediately based on sanitize_cb’ is closed to new replies.