Skip to content

Commit

Permalink
xhtml fix - now only 'for=' with wrong id is removed from labels - st…
Browse files Browse the repository at this point in the history
…atic and grouped elemenst (date selector), because the missing label might cause problems with CSS styling
  • Loading branch information
skodak committed Jan 8, 2007
1 parent 0fd5fee commit 18f3ad8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/formslib.php
Expand Up @@ -1369,9 +1369,6 @@ function renderElement(&$element, $required, $error){
$html = str_replace('{help}', '', $html);

}
if ($element->getType() == 'static') {
$html = preg_replace('/(<label.*?>)|(<\/label>)/i', '', $html); //xhtml compliance - no label for static content
}
$this->_templates[$element->getName()] = $html;
if (!is_null($element->getAttribute('id'))) {
$id = $element->getAttribute('id');
Expand All @@ -1383,6 +1380,11 @@ function renderElement(&$element, $required, $error){
$element->updateAttributes(array('id'=>'id_'.$id));
}
parent::renderElement($element, $required, $error);
if ($element->getType() == 'static' or $element->getType() == 'date_selector' or $element->getType() == 'date_time_selector') {
//xhtml compliance - remove 'for' attribute from label if element with id does not exist
//TODO: is there a better way to do it?
$this->_html = str_replace('<label for="id_'.$element->getName().'">', '<label>', $this->_html);
}
}

function finishForm(&$form){
Expand Down

0 comments on commit 18f3ad8

Please sign in to comment.