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
This commit is contained in:
Will Rossiter 2008-08-18 00:10:26 +00:00
parent 6178a9838d
commit cdb19344bf
2 changed files with 6 additions and 3 deletions

View File

@ -6,7 +6,7 @@
*/
class PageComment extends DataObject {
static $db = array(
"Name" => "Varchar",
"Name" => "Varchar(200)",
"Comment" => "Text",
"IsSpam" => "Boolean",
"NeedsModeration" => "Boolean"

View File

@ -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