Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Add fields to PageComments form?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1 2
Go to End
Author Topic: 3850 Views
  • drye
    Community Member
    49 Posts

    Re: Add fields to PageComments form? Link to this post

    EDIT: Just to update this "answer" I wrote a tutorial on SSbits (http://ssbits.com/adding-fields-to-page-comments/) - Hope it helps


    Let me explain what I have done, in my examples I am adding an email field. Also note that while this does manage to add the field the the CMS CTF (Complex Table Field) it fails to add it to the popup.

    Here goes:
    File added - CommentAdminDecorator.php (in mysite directory)


    /*Copied EditForm from CommentAdmin.php version 2.3.1
    - Added Email field
    class CommentAdminDecorator extends LeftAndMainDecorator {

    public function Link(){ //had to add errors out as missing function if not
    return $this->owner->Link();
       public function MyEditForm() {//Was originally EditForm, wasn't showing in the template so I had to create my own template
          $tableFields = array(
             "Name" => _t('CommentAdmin.AUTHOR', 'Author'),
             "Comment" => _t('CommentAdmin.COMMENT', 'Comment'),
             "CommenterEmail" => _t('CommentAdmin.COMMENTEREMAIL', 'Email'),
             "PageTitle" => _t('CommentAdmin.PAGE', 'Page'),
             "CommenterURL" => _t('CommentAdmin.COMMENTERURL', 'URL'),
             "Created" => _t('CommentAdmin.DATEPOSTED', 'Date Posted')
          $popupFields = new FieldSet(
             new TextField('Name', _t('CommentAdmin.NAME', 'Name')),
             new TextField('CommenterEmail', _t('CommentAdmin.COMMENTEREMAIL', 'Email')),
             new TextField('CommenterURL', _t('CommentAdmin.COMMENTERURL', 'URL')),
             new TextareaField('Comment', _t('CommentAdmin.COMMENT', 'Comment'))

    File added - CommentAdmin_right.ss (in templates/Includes)

    <div id="form_actions_right" class="ajaxActions">

    <% if MyEditForm %>
    <% else %>
       <form id="Form_EditForm" action="admin/comments?executeForm=EditForm" method="post" enctype="multipart/form-data">
          <p><% _t('WELCOME1', 'Welcome to the') %> $ApplicationName <% _t('WELCOME2', 'comment management. Please select a folder in the tree on the left.') %></p>
    <% end_if %>

    <p id="statusMessage" style="visibility:hidden"></p>

    I hope this helps! If anyone comes up with why my popup isn't picking up the field please let me know!


Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.