- This topic has 4 replies, 2 voices, and was last updated 1 month, 1 week ago by .
-
Topic
-
Hi,
I have a text field in a block and set a callback_function in order to format the input data but it is not working.
What am I doing wrong?
This is how I defined the block with the amount text field:add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = ''; $meta_boxes[] = [ 'title' => esc_html__( 'Test BLCK', 'text-domain' ), 'id' => 'test-blck', 'fields' => [ [ 'id' => $prefix . 'text_hdsmywqrchf', 'type' => 'text', 'name' => esc_html__( 'Text Field Test BLCK', 'text-domain' ), ], [ 'id' => $prefix . 'taxonomy_advanced_yhwon6kcqb', 'type' => 'taxonomy_advanced', 'name' => esc_html__( 'Taxonomy Advanced Field', 'text-domain' ), 'taxonomy' => 'test-type', 'field_type' => 'select', ], [ 'id' => $prefix . 'text_ey3ewpvlke', 'type' => 'text', 'name' => esc_html__( 'Amount text field', 'text-domain' ), 'size' => 16, 'columns' => 12, 'sanitize_callback' => 'xn_sanitize_money_field', ], ], 'category' => 'layout', 'icon' => 'admin-appearance', 'type' => 'block', 'mode' => 'edit', ]; return $meta_boxes; }
This is my callback function defined in my functions.php:
function xn_sanitize_money_field ($value) { // Do something with $value. $number = floatval ( $value ); $value_new = number_format ($number, 2, ",", "."); return $value_new; }
And this is my problem:
https://share.getcloudapp.com/OAuWJv9m
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.