Check that the html is valid: - each field must have an id - each field must have a label
(self)
| 551 | return fields[0] |
| 552 | |
| 553 | def lint(self): |
| 554 | """ |
| 555 | Check that the html is valid: |
| 556 | |
| 557 | - each field must have an id |
| 558 | - each field must have a label |
| 559 | |
| 560 | """ |
| 561 | labels = self._label_re.findall(self.text) |
| 562 | for name, fields in self.fields.items(): |
| 563 | for field in fields: |
| 564 | if not isinstance(field, (Submit, Hidden)): |
| 565 | if not field.id: |
| 566 | raise AttributeError("%r as no id attribute" % field) |
| 567 | elif field.id not in labels: |
| 568 | raise AttributeError( |
| 569 | "%r as no associated label" % field) |
| 570 | |
| 571 | def set(self, name, value, index=None): |
| 572 | """Set the given name, using ``index`` to disambiguate.""" |