function toHtml() {
global $CFG, $PAGE;
+ $this->_generateId();
+ $elementid = $this->getAttribute('id');
$mainhtml = html_writer::tag('div', $this->items[$this->getValue()]->mainhtml,
- array('id' => $this->getName().'_items_main', 'class' => 'formlistingmain'));
+ array('id' => $elementid . '_items_main', 'class' => 'formlistingmain'));
// Add the main div containing the selected item (+ the caption: "More items").
$html = html_writer::tag('div', $mainhtml .
html_writer::tag('div', $this->showall,
- array('id' => $this->getName().'_items_caption', 'class' => 'formlistingmore')),
- array('id'=>$this->getName().'_items', 'class' => 'formlisting hide'));
+ array('id' => $elementid . '_items_caption', 'class' => 'formlistingmore')),
+ array('id' => $elementid . '_items', 'class' => 'formlisting hide'));
// Add collapsible region: all the items.
$itemrows = '';
$html .= html_writer::tag('div', $itemrows,
- array('id' => $this->getName().'_items_all', 'class' => 'formlistingall'));
+ array('id' => $elementid . '_items_all', 'class' => 'formlistingall'));
// Add radio buttons for non javascript support.
$radiobuttons = '';
// Container for the hidden hidden input which will contain the selected item.
$html .= html_writer::tag('div', $radiobuttons,
- array('id' => 'formlistinginputcontainer_' . $this->getName(), 'class' => 'formlistinginputcontainer'));
+ array('id' => 'formlistinginputcontainer_' . $elementid, 'class' => 'formlistinginputcontainer'));
$module = array('name'=>'form_listing', 'fullpath'=>'/lib/form/yui/listing/listing.js',
'requires'=>array('node', 'event', 'transition', 'escape'));
$PAGE->requires->js_init_call('M.form_listing.init',
array(array(
- 'elementid' => $this->getName().'_items',
+ 'elementid' => $elementid.'_items',
'hideall' => $this->hideall,
'showall' => $this->showall,
'hiddeninputid' => $this->getAttribute('id'),
'items' => $this->items,
- 'inputname' => $this->getName(),
+ 'inputname' => $elementid,
'currentvalue' => $this->getValue())), true, $module);
return $html;