David Nash

Wordpress Guru Sydney

Remove empty LEGEND tags in Silverstripe search form

Posted on May 1, 2009

I’m pretty obsessive about my HTML validating with no errors and no warnings. It bugs me that when I use Silverstripe’s incredibly convenient $Searchform in the template that it outputs an empty legend tag inside the fieldset.

There’s an easy way to fix this:

  1. Create a templates directory inside mysite.
  2. Copy sapphire/templates/SearchForm.ss to mysite/templates/SearchForm.ss
  3. Edit your copy of the file and remove that pesky <legend></legend> line
  4. Refresh your page that uses the searchform and bathe in the warm glow of a error and warning free page!

Thanks to Maksfeltrin in the Silverstripe forums for pointing this out.

  1. Have you considered supplying a patch at open.silverstripe.com so that the product sees the improvement? :)

  2. Dieter says:

    Hmm, I can understand your concern, but since when is leaving out the legend valid html (strict)?

  3. David says:

    Hi Dieter – empty legend tags are valid; my (admittedly petty) issue is that the HTML Validator add-on I use in FIrefox generates a warning that it is trimming empty elements.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>