Menu

#219 "select"s without "option"s should not be posted

open
nobody
None
5
2012-10-16
2012-10-16
Anonymous
No

if a form is loaded with a select field that does not have any option tags, most browsers will not post the field back at all. this is critical in some ASP applications where the site expects the field to be omitted, and when it is included causes the viewstate not to validate (i didn't write the site but it gave me a headache trying to figure it out). this is easily fixed by adding 1 line of code on line 239 in tidy_parser.php

change:

private function addWidgetToForm($node, $form, $enclosing_label) {
$widget = $this->tags()->createTag($node->name, $this->attributes($node));
if (! $widget) {
return;
}
$widget->setLabel($enclosing_label)
->addContent($this->innerHtml($node));
if ($node->name == 'select') {
$widget->addTags($this->collectSelectOptions($node));
}
$form->addWidget($widget);
$this->indexWidgetById($widget);
}

to:

private function addWidgetToForm($node, $form, $enclosing_label) {
$widget = $this->tags()->createTag($node->name, $this->attributes($node));
if (! $widget) {
return;
}
$widget->setLabel($enclosing_label)
->addContent($this->innerHtml($node));
if ($node->name == 'select') {
if(count($widget->addTags($this->collectSelectOptions($node))) == 0){
return;
}
}
$form->addWidget($widget);
$this->indexWidgetById($widget);
}

Discussion


Log in to post a comment.