Skip to content

Problem on render decimals value backend #13

@cicoph

Description

@cicoph

Before save the value on DB the code replace the current decimal separator with dot (and also remove the thousand separator). On render the value on backed you must replace the dot separator decimals with the selected separator:
For V5
public function render_field( $field ) { $format = $this->parse_format( $field['format'] ); $field['value'] = str_replace( '.', $format['decimal_point'], $field['value'] ); ?> <input type="text" id="<?php echo $field['id'] ?>" class="acf_price" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($field['value']) ?>" data-format-decimals="<?php echo $format['decimals'] ?>" data-format-decimal_point="<?php echo $format['decimal_point'] ?>" data-format-thousands_separator="<?php echo $format['thousands_separator'] ?>" /> <?php }
For V4

function create_field( $field ) { $format = $this->parse_format( $field['format'] ); $field['value'] = str_replace( '.', $format['decimal_point'], $field['value'] ); ?> <input type="text" id="<?php echo $field['id'] ?>" class="acf_price" name="<?php echo esc_attr($field['name']) ?>" value="<?php echo esc_attr($field['value']) ?>" data-format-decimals="<?php echo $format['decimals'] ?>" data-format-decimal_point="<?php echo $format['decimal_point'] ?>" data-format-thousands_separator="<?php echo $format['thousands_separator'] ?>" /> <?php }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions