Support

Account

Home Forums General Issues How to create "table of (numeric input) fields" Reply To: How to create "table of (numeric input) fields"

  • // Upon *new* post only 
    add_filter('acf/load_value/key=field_5ff3a123b5198', 'build_participants_table', 20, 3);
    ....
    function build_participants_table($value, $post_id, $field){
        //error_log('build_participants_table field='. print_r($field, true));
        $ptypes = array(/* participants segments*/ 'men', 'women', 'children'); // etc...
        foreach ($ptypes as $ptype){
            $value[] = array(
                'field_5ff3c5f44a5d1' => $ptype,
                'field_5ff3c4debd753' => 0,
                'field_5ff3c514bd754' => 0,
                'field_5ff3c52abd755' => 0,
                'field_5ff3c543bd756' => 0,
            );
        }
        return $value;
    }