Single attributes
Quintin Connell <[email protected]>
| Newsgroups | gmane.comp.gcc.cgicc.general |
|---|---|
| Message-ID | <[email protected]> |
A number of HTML attributes only require a name, and not a name = "value" pair.
Notably the selected, checked and readonly tags when dealing with forms. The
current behaviour if you set any of these is to get the following output in your
HTML <input type="text" name="txtBox" value="My Text" readonly="readonly" />.
This appears to work, esp for the checked and selected tags of radio buttons/
check boxes and select options. But I don't think this is quite what was
intended.
The HTMLAttribute class does provide a constructor that accepts one parameter,
but that parameter is mirrored to both the name and the value members. I propose
a change as follows to the constructor
CGICCNS HTMLAttribute::HTMLAttribute(const STDNS string& name)
: fName(name),
fValue()
{}
and hence the render member function can be changed as follows:
void
CGICCNS HTMLAttribute::render(STDNS ostream& out) const
{
if (!getValue().empty()) {
out << getName() << "=\"" << getValue() << "\"";
}
else {
out << getName();
}
}
Which would then render the attribute as expected.
Quintin