HTML5 Comment Forms in b2evolution

Following my post last week on HTML5 forms it occurred to me that I should be a little embarrassed devoting all this time to writing about HTML5 when my blog makes use of no HTML5 features. A quick hack around with the template corrected the DOCTYPE and I was looking for some other quick changes I could make without getting into to a full redesign (currently in process for about 5 months...). The comments form seemed an obvious target and turns out to be remarkably easy to do in b2evo.

The file you need to edit is _item_comment_form.inc.php, which will live inside your skins directory. If you have a custom skin set up you may also find inside the directory for that skin, these instructions assume you'll be editing the standard _item_comment_form.inc.php, whether in the skins directory or in a folder in that directory.

The parts we need to edit are on lines 142 and 143, the fields for email and website address:

$Form->text( 'i', $comment_author_email, 40, T_('Email'), '<br />'.T_('Your email address will <strong>not</strong> be revealed on this site.'), 100, 'bComment' );
$Form->text( 'o', $comment_author_url, 40, T_('Website'), '<br />'.T_('Your URL will be displayed.'), 100, 'bComment' );

The text method on the $Form object can take an optional sixth parameter which determines the input type. So to create HTML5 email and url inputs, simply add that sixth parameter:

$Form->text( 'i', $comment_author_email, 40, T_('Email'), '<br />'.T_('Your email address will <strong>not</strong> be revealed on this site.'), 100, 'bComment', 'email' );
$Form->text( 'o', $comment_author_url, 40, T_('Website'), '<br />'.T_('Your URL will be displayed.'), 100, 'bComment', 'url' );