post by dan on Jan 19, 2023

This is my function, and it pulls the value in but only the once, it’s very strange. Is there some caching going on somewhere?

    // New ID Function

    public function newid()
        {
            // 
            $db      = \Config\Database::connect();

            $builder = $db->table('radios');
            $query = $builder->get();
            if($builder->countAllResults() > 0){
                // Return latest ID
                $builder->selectMax('radioID');
                $builder->get();
                $row = $query->getRow();
                $topID = $row->radioID;
                //print_r($topID);
                $topID++;
                return $topID;
            }
        }

post by dan on Jan 19, 2023

I’ve tried calling this function from within the callback function…
It still only shows the value that would have been in the database the first time the page loaded.

        $crud->callbackAddField('radioID', function() {
            return '<input class="form-control" name="radioID" type="text" value="' . $this->newid() . '" readonly>';
        });
21 / 22
Jan 2023