From 648cf3397d349b0b4b0fa0db8fa728a1fdd0a107 Mon Sep 17 00:00:00 2001 From: Anthony Forth Date: Tue, 31 Jan 2012 17:10:51 +0000 Subject: [PATCH] MDL-31445 formslib: add a nice id and class to the wrapper div for CSS --- lib/formslib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index 0818fbe751512..0f06fcff0b862 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -2229,9 +2229,9 @@ function MoodleQuickForm_Renderer(){ // switch next two lines for ol li containers for form items. // $this->_elementTemplates=array('default'=>"\n\t\t".'
  • {error}
    {element}
  • '); $this->_elementTemplates = array( - 'default'=>"\n\t\t".'
    {error}
    {element}
    ', + 'default'=>"\n\t\t".'
    {error}
    {element}
    ', - 'fieldset'=>"\n\t\t".'
    {error}
    {element}
    ', + 'fieldset'=>"\n\t\t".'
    {error}
    {element}
    ', 'static'=>"\n\t\t".'
    {error}
    {element} 
    ', @@ -2276,6 +2276,9 @@ function startForm(&$form){ * @param mixed $error */ function startGroup(&$group, $required, $error){ + // Make sure the element has an id. + $group->_generateId(); + if (method_exists($group, 'getElementTemplateType')){ $html = $this->_elementTemplates[$group->getElementTemplateType()]; }else{ @@ -2299,6 +2302,7 @@ function startGroup(&$group, $required, $error){ }else{ $html =str_replace('{help}', '', $html); } + $html =str_replace('{id}', 'fgroup_' . $group->getAttribute('id'), $html); $html =str_replace('{name}', $group->getName(), $html); $html =str_replace('{type}', 'fgroup', $html); @@ -2349,6 +2353,7 @@ function renderElement(&$element, $required, $error){ } else { $html =str_replace('{advancedimg}', '', $html); } + $html =str_replace('{id}', 'fitem_' . $element->getAttribute('id'), $html); $html =str_replace('{type}', 'f'.$element->getType(), $html); $html =str_replace('{name}', $element->getName(), $html); if (method_exists($element, 'getHelpButton')){