From a019627a1a5b94cf7ab5e58a61f25968fc699a33 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 28 Aug 2009 11:38:33 +0000 Subject: [PATCH] MDL-19756 Fixed bug in output of fields with a label --- lib/outputcomponents.php | 12 ++++++++++-- lib/outputrenderers.php | 6 +++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index cdb7132811..72a4cb094f 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -1163,13 +1163,21 @@ class html_table_row extends moodle_html_component { } /** - * Shortcut method for creating a row with an array of cells. + * Shortcut method for creating a row with an array of cells. Converts cells to html_table_cell objects. * @param array $cells * @return html_table_row */ public function make($cells=array()) { $row = new html_table_row(); - $row->cells = $cells; + foreach ($cells as $celltext) { + if (!($celltext instanceof html_table_cell)) { + $cell = new html_table_cell(); + $cell->text = $celltext; + $row->cells[] = $cell; + } else { + $row->cells[] = $celltext; + } + } return $row; } } diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 1d788c47a5..bb6ed3344c 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -1845,11 +1845,11 @@ class moodle_core_renderer extends moodle_renderer_base { $field = clone($field); $field->prepare(); $this->prepare_event_handlers($field); - $returned = ''; + $label = ''; if (!empty($field->label->text)) { - $returned .= $this->label($field->label); + $label = $this->label($field->label); } - $returned .= $this->output_empty_tag('input', array( + return $label . $this->output_empty_tag('input', array( 'type' => $field->type, 'name' => $field->name, 'id' => $field->id, -- 2.39.5