From cdb19344bf163c90bd49ce602f11e745436d278e Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Mon, 18 Aug 2008 00:10:26 +0000 Subject: [PATCH] BUGFIX: fixed Member name not being saved in database with ReadonlyField() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@60897 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/sitefeatures/PageComment.php | 2 +- code/sitefeatures/PageCommentInterface.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/sitefeatures/PageComment.php b/code/sitefeatures/PageComment.php index 3bab07e1..5799d133 100755 --- a/code/sitefeatures/PageComment.php +++ b/code/sitefeatures/PageComment.php @@ -6,7 +6,7 @@ */ class PageComment extends DataObject { static $db = array( - "Name" => "Varchar", + "Name" => "Varchar(200)", "Comment" => "Text", "IsSpam" => "Boolean", "NeedsModeration" => "Boolean" diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index ba1efb59..4db67210 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -113,7 +113,11 @@ class PageCommentInterface extends RequestHandlingData { $member = Member::currentUser(); if((self::$comments_require_login || self::$comments_require_permission) && $member && $member->FirstName) { - $fields->push(new ReadonlyField("Name", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName())); + // note this was a ReadonlyField - which displayed the name in a span as well as the hidden field but + // it was not saving correctly. Have changed it to a hidden field. It passes the data correctly but I + // believe the id of the form field is wrong. + $fields->push(new ReadonlyField("NameView", _t('PageCommentInterface.YOURNAME', 'Your name'), $member->getName())); + $fields->push(new HiddenField("Name", "", $member->getName())); } else { $fields->push(new TextField("Name", _t('PageCommentInterface.YOURNAME', 'Your name'))); } @@ -206,7 +210,6 @@ class PageCommentInterface_Form extends Form { return "spamprotectionfailed"; //used by javascript for checking if the spam question was wrong } } - Cookie::set("PageCommentInterface_Name", $data['Name']); // If commenting can only be done by logged in users, make sure the user is logged in