• Resolved ioclaudio

    (@ioclaudio)


    Hi,
    is it possible to pre-fill the field “Advanced Custom Fields: Table Field”.
    I’d like that when I create a post the table has the header row already filled with 6 columns.
    For example like this image: https://ibb.co/TYChMVr

    Thank you very much

    Claudio

    • This topic was modified 5 years ago by ioclaudio.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter ioclaudio

    (@ioclaudio)

    biostim

    (@biostim)

    Hi ioclaudio,
    Thank you for the reply. I followed these links but can’t understand them as not sure for to fit to a table. Any chance you can post code/steps?

    Kind regards
    Tim Lester

    Thread Starter ioclaudio

    (@ioclaudio)

    function my_acf_prepare_field( $field ) {
        error_log("######".json_encode($field["value"])."######");
        $l_defaultTable = '{"acftf":{"v":"1.3.9"},"p":{"o":{"uh":1},"ca":""},"c":[{"p":""},{"p":""},{"p":""},{"p":""},{"p":""},{"p":""}],"h":[{"c":"Data"},{"c":"Orario"},{"c":"Tipologia"},{"c":"Preiscrizioni"},{"c":"Iscrizioni"},{"c":"Risultati"}],"b":[[{"c":""},{"c":""},{"c":""},{"c":""},{"c":""},{"c":""}]]}';
        if ($field["value"]==null) {
            error_log("@@@ Trovato NULL @@@");
            $field["value"] = $l_defaultTable;
        } else if (is_array($field["value"])) {
            $l_jsonString = json_encode($field["value"]);
            if (strpos($l_jsonString, 'Data') == false) {
                $field["value"] = $l_defaultTable;
            }
        } else {
            error_log("@@@ Non trovato NULL @@@");
        }
        return $field;
    }
    • This reply was modified 5 years ago by ioclaudio.
    biostim

    (@biostim)

    Still a bit too complex for me but thank you as I might hire someone to solve it for my situation.

    Cheers
    Tim

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to prefill the Table field?’ is closed to new replies.