Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Customising the Comment Form HTML


Reply

10 Posts   6100 Views

Avatar
chris_d

22 July 2009 at 2:38pm Community Member, 21 Posts

had a look at this too
a google search for postcommentform silverstripe
returns http://www.silverstripe.org/archive/show/247213

Avatar
markguinn

11 December 2009 at 4:51am (Last edited: 11 December 2009 4:53am), Community Member, 13 Posts

Copy the file /cms/templates/PageCommentInterface.ss to your theme's templates folder, replace:

   <% if CanPostComment %>
      <h4><% _t('POSTCOM','Post your comment') %></h4>
      
      $PostCommentForm
   <% else %>

With the following:

   <% if CanPostComment %>
      <% control PostCommentForm %>
       <h4><% _t('POSTCOM','Post your comment') %></h4>
      
         <% if IncludeFormTag %>
         <form $FormAttributes>
         <% end_if %>
            <% if Message %>
            <p id="{$FormName}_error" class="message $MessageType">$Message</p>
            <% else %>
            <p id="{$FormName}_error" class="message $MessageType" style="display: none"></p>
            <% end_if %>
            
            <fieldset>
               <legend>$Legend</legend>
               <% control Fields %>
                  $FieldHolder
               <% end_control %>
               <div class="clear"><!-- --></div>
            </fieldset>
         
            <% if Actions %>
            <div class="Actions">
               <% control Actions %>
                  $Field
               <% end_control %>
            </div>
            <% end_if %>
         <% if IncludeFormTag %>
         </form>
         <% end_if %>
      
      <% end_control %>
   <% else %>

This is essentially pasting the contents of the default Form.ss template into the overridden template inline. You should be able to then make any changes you want to make, including specifying the fields explicitly (see [url]http://doc.silverstripe.org/doku.php?id=form[/url] under "Using a custom template" for more information about what that would look like).

That's the best way I can see to do it without modifying system classes. I know this question was asked several months ago, but this is probably a common question, so hopefully it will help someone.

Mark