Well, in html terms a form usually looks something like this:
My Form
Foo:
Bar:
According to the
specs and the DTD a label MUST have a for attribute and it must have a corresponding id on the form control (like input | textarea | button | select ).
A label is allowed to include any inline content (except another label) or PCDATA (text). I've actually never seen anyone put anything but text in a label but it is allowed. If you just wanted it to be simple you can have 1 function that creates "$text" or you could have 1 to make a "" and another 1 for a "". Personally I would like the first because it's simpler and I have never had use for putting complicated stuff inside a label. for example:
Code: Select all
/**
* Returns the xhtml equivalent of a label. This is basically a nice little wrapper
*
* @param string The id given to the module on execution
* @param string The html for of the label
* @param string The contents of the label
* @param string Any additional text that should be added into the tag when rendered
*/
}
function CreateLabel($id, $for, $value='', $addtext='')
{
return "<label for='$id$for' $addtext >$value</label>\n"
}
More importantly you need change the CreateInputText and the other functions to include an id parameter. I.e.
Code: Select all
function CreateInputText($id, $name, $value='', $size='10', $maxlength='255', $addttext='', $idparam='')
{
$value = str_replace('"', '"', $value);
$text = '<input type="text" name="'.$id.$name.'" value="'.$value.'" size="'.$size.'" maxlength="'.$maxlength.'"';
if ($addttext != '')
{
$text .= ' ' . $addttext;
}
if ($idparam != '')
{
$text .= " id='$id$idparam'";
}
$text .= " />\n";
return $text;
}