LMSouq
moodle-core Open

Moodle flexible_table shows empty first row

ST
StartVader
1 month ago
3 views
Problem Description
After changing in **Moodle** the **html_table** into **flexible_table**, I get the first **row** as completely **empty** and because of that the **sorting** doesn't work. I changes the tables, because the html_table doesn't have sorting capabilities. The code is: ob_start(); $table = new flexible_table('Cars'); $table->define_baseurl(new moodle_url("/blocks/cars/view.php")); $table->define_columns(array( 'carname', 'carnumberplate', 'carhiredate', 'city', 'actions', )); $table->define_headers(array( get_string('carname', 'block_cars'), get_string('carnumberplate', 'block_cars'), get_string('carhiredate', 'block_cars'), get_string('city', 'block_cars'), get_string('actions') )); $table->sortable(true, 'cars'); $table->collapsible(false); $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'view-block-cars'); $table->set_attribute('class', 'generaltable'); $table->setup(); // Add one blank line $table->add_data(NULL); $strdateformat = get_string('strftimedate'); $strtimeformat = get_string('strftimetime'); foreach ($cars as $car) { $datestart = userdate($car->starttime, $strdateformat); $dateend = userdate($car->endtime, $strdateformat); $timestart = userdate($car->starttime, $strtimeformat); $timeend = userdate($car->endtime, $strtimeformat); $date = $datestart; if ($datestart != $dateend) { $date .= ' - '.$dateend; } $time = $timestart.' - '.$timeend; $actions = array( html_writer::link($car->get_view_url(), get_string('view')), ); $actions = implode(' | ', $actions); $row = array( format_string($car->carname), format_string($car->platenumber), $date, format_string($car->city),...

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base