Problem
Upon calling fetch(), a label tag is rendered for every element even if there was no label property specified when creating the element. This especially is a disturbance with buttons (which may not need a label) and xhtml elements, because it may mess up the layout (depending on the css).
Steps to reproduce
This is an example controller action:
public function actionTest() {
$this->formanm = Solar::factory('Solar_Form');
$this->formanm->setElements(
array(
'surname' => array(
'type' => 'text',
'label' => 'Surname, Forename',
),
'forename' => array(
'type' => 'text',
),
'process' => array(
'type' => 'submit',
'value' => 'Register',
),
));
Proposed solution
in Solar/View/Helper/Form.php, change line 733 from
$form[] = " <dt$require><label$require for=\"$id\">$label</label>$dt_descr</dt>";
to
if (strlen($label) > 0) {
$form[] = " <dt$require><label$require for=\"$id\">$label</label>$dt_descr</dt>";
}
And line 751 from
$form[] = " <dt><label>$label</label></dt>";
else
if (strlen($label) > 0) {
$form[] = " <dt><label>$label</label></dt>";
}
Remark: Maybe it would be cleaner to check against null (thus allowing an empty label if the user wants it that way), but this would require more changes (line 654, and the content of $infolabel?)