Why not:

```jinja
<tr{% if form.cart_line.error %} class="danger"{% endif %}>
```

And why does it need this at row level? We don't do that for invalid quantities.