Merge pull request #122 from tractorcow/pulls/paren-comment-context

API Add readonly parent details in comment form in CMS
This commit is contained in:
Christopher Pitt 2015-04-23 10:09:16 +12:00
commit 8d987e3336
1 changed files with 37 additions and 0 deletions

View File

@ -561,6 +561,43 @@ class Comment extends DataObject {
);
}
// Show parent comment if given
if(($parent = $this->ParentComment()) && $parent->exists()) {
$fields->push(new HeaderField(
'ParentComment_Title',
_t('Comment.ParentComment_Title', 'This comment is a reply to the below')
));
// Created date
$fields->push(
$parent
->obj('Created')
->scaffoldFormField($parent->fieldLabel('Created'))
->setName('ParentComment_Created')
->setValue($parent->Created)
->performReadonlyTransformation()
);
// Name (could be member or string value)
$fields->push(
$parent
->obj('AuthorName')
->scaffoldFormField($parent->fieldLabel('AuthorName'))
->setName('ParentComment_AuthorName')
->setValue($parent->getAuthorName())
->performReadonlyTransformation()
);
// Comment body
$fields->push(
$parent
->obj('EscapedComment')
->scaffoldFormField($parent->fieldLabel('Comment'))
->setName('ParentComment_EscapedComment')
->setValue($parent->Comment)
->performReadonlyTransformation()
);
}
$this->extend('updateCMSFields', $fields);
return $fields;
}