Support

Account

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

Helping

How to create "table of (numeric input) fields"

  • I need a “table of (numeric input) fields” – not a repeater, not “field table type”,
    but a fixed, tabular structure. Simply because its the most intuitive way to display the data.

    I wish to collect report on number of participants (in my example).

    Each row represenet segment like men, women, children, age X, age Y, etc…
    Each column represents a phase: starting, finshed, dropped, cancelled, etc…
    Each cell type is a number.

    How can I achieve it, in a simple tabular structure?
    Is there some HTML trick?

  • // 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;
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.