Commit 494d4693 authored by alexpott's avatar alexpott

Issue #2099421 by larowlan: Add an administrative description for a comment field.

parent 0c4e489a
......@@ -147,6 +147,9 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment',
'name' => $field_name,
'type' => 'comment',
'translatable' => '0',
'settings' => array(
'description' => 'Default comment field',
),
));
// Create the field.
$field->save();
......
......@@ -80,6 +80,10 @@ public function __construct(FieldInfo $field_info, CommentManagerInterface $comm
public function overviewBundles() {
$header = array(
'field_name' => $this->t('Field name'),
'description' => array(
'data' => $this->t('Description'),
'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
),
'usage' => array(
'data' => $this->t('Used in'),
'class' => array(RESPONSIVE_PRIORITY_MEDIUM),
......@@ -118,6 +122,7 @@ public function overviewBundles() {
);
$row['data']['field_name']['data'] = $field_info->get('locked') ? $this->t('@label (@field_name) (Locked)', $tokens) : $this->t('@label (@field_name)', $tokens);
$row['data']['description']['data'] = $field_info->getSetting('description');
$row['data']['usage']['data'] = array(
'#theme' => 'item_list',
'#items' => array(),
......
......@@ -18,6 +18,9 @@
* id = "comment",
* label = @Translation("Comments"),
* description = @Translation("This field manages configuration and presentation of comments on an entity."),
* settings = {
* "description" = "",
* },
* instance_settings = {
* "default_mode" = COMMENT_MODE_THREADED,
* "per_page" = 50,
......@@ -195,4 +198,19 @@ public static function processSettingsElement($element) {
return $element;
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, array &$form_state, $has_data) {
$element = array();
$element['description'] = array(
'#type' => 'textarea',
'#title' => t('Field description'),
'#description' => t('Describe this comment field. The text will be displayed on the <em>Comments Forms</em> page.'),
'#default_value' => $this->getSetting('description'),
);
return $element;
}
}
......@@ -162,6 +162,9 @@ public function testCommentAdmin() {
// Make sure titles visible.
$this->assertText('Field name');
$this->assertText('Used in');
$this->assertText('Description');
// Make sure the description is present.
$this->assertText('Default comment field');
// Manage fields.
$this->clickLink('Manage fields');
$this->assertResponse(200);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment