'#description' =>
$this->
t('Users with the "Post comments" permission can post comments.'
),
],
CommentItemInterface::CLOSED =>
[ '#description' =>
$this->
t('Users cannot post comments, but existing comments will be displayed.'
),
],
CommentItemInterface::HIDDEN =>
[ '#description' =>
$this->
t('Comments are hidden from view.'
),
],
];
// Setting a value in the default value widget is required.
if ($this->
isDefaultValueWidget($form_state)) { $element['status'
]['#required'
] = TRUE;
} // If the entity doesn't have any comments, the "hidden" option makes no
// sense, so don't even bother presenting it to the user unless this is the
// default value widget on the field settings form.
if (!
$this->
isDefaultValueWidget($form_state) && !
$items->comment_count
) { $element['status'
][CommentItemInterface::HIDDEN
]['#access'
] = FALSE;
// Also adjust the description of the "closed" option.
$element['status'
][CommentItemInterface::CLOSED
]['#description'
] =
$this->
t('Users cannot post comments.'
);
}