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.

General Questions

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

Add fields to PageComments form?


Reply

9 Posts   3886 Views

Avatar
drye

4 January 2010 at 8:36pm (Last edited: 5 June 2010 2:56pm), Community Member, 49 Posts

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

@MarijnKampf

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)

<?php

/*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">
</div>

<% if MyEditForm %>
   $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>
   </form>
<% 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!

-Dan