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.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Add fields to PageComments form

Go to End

3 Posts   2427 Views


Community Member, 18 Posts

10 December 2008 at 11:28pm

I'm trying to add some fields to the $PageComments form. To do this I use the DataObjectDecorator to extend the PageCommentInterface. To start simple I overload the PostCommentForm and alter the field 'Your name' to 'Your - test - name'. Problem is that the 'default' form with 'Your name' is showing. Hopefully someone could give me a clue on what I'm doing wrong here? Thanks!


class CustomCommentInterface extends DataObjectDecorator

	function forTemplate()
		return $this->renderWith('CustomCommentInterface');
	function PostCommentForm() {
		$fields = new FieldSet(
			new HiddenField("ParentID", "ParentID", $this->page->ID),
			new TextField("Name", _t('CustomCommentInterface.YOURNAME', 'Your - test - name')));	
			$fields->push(new TextField("Math", sprintf(_t('CustomCommentInterface.SPAMQUESTION', "Spam protection question: %s"), MathSpamProtection::getMathQuestion())));
		$fields->push(new TextareaField("Comment", _t('CustomCommentInterface.YOURCOMMENT', "Comments")));
		$form = new PageCommentInterface_Form($this->controller, $this->methodName . ".PostCommentForm",$fields, new FieldSet(
			new FormAction("postcomment", _t('CustomCommentInterface.POST', 'Post'))
			"Name" => Cookie::get("CustomCommentInterface_Name"),
		return $form;


Object::add_extension('PageCommentInterface', 'CustomCommentInterface');


Community Member, 18 Posts

14 December 2008 at 9:00am

Browsing the docs and forum some more but can't seem to find what I'm missing here. Someone? Anyway, thanks for your time!


Community Member, 215 Posts

14 December 2008 at 7:54pm

Hey, I am not sure if this is what you are looking for but I added an email field to page comments although I did it by changing the core so there is prolly way to do it without hacking. The diff file i generated is here which should give you an idea of what worked.

Good luck