Problem to show current value in the listing grid

0

In WordPress I created a "custom post type" post type named Campaigns, inside it I integrated a form made with "ACF". This form has repeating fields of type "number" where points are registered.

At the end of this form there is a field that adds numeric and total fields. To display this field an extension of the ACF was developed to add the value. It works right, saves, shows sum total and everything. However, when displaying the "grid" list, the saved value does not appear but the previous value.

Follow the plugin code acf-sum-v5.php

<?php
class acf_field_sum extends acf_field {
    function __construct() {
        $this->name = 'sum_id';
        $this->label = __('Sum Fields Number', 'acf-sum');
        $this->category = 'layout';
        $this->l10n = array(
        );
        parent::__construct();
    }
    function render_field( $field ) {
        ?>
<label for="total">Total:</label>
<input id="total" readonly name="<?php echo esc_attr($field['name']) ?>">

<script type="text/javascript">
let total = 0;
document.querySelectorAll('input[type="number"]').forEach(el=>total+=+el.value);
document.querySelector('#total').value = total;
console.log(total);
</script>
        <?php
    }
}
// create field
new acf_field_sum();

If someone can help me in this, I thank them very much.

    
asked by anonymous 26.03.2018 / 19:43

0 answers