if ($comment->
id()) { $date = !
empty($comment->date
) ?
$comment->date : DrupalDateTime::
createFromTimestamp($comment->
getCreatedTime());
} // The uid field is only displayed when a user with the permission
// 'administer comments' is editing an existing comment from an
// authenticated user.
$owner =
$comment->
getOwner();
$form['author'
]['uid'
] =
[ '#type' => 'entity_autocomplete',
'#target_type' => 'user',
'#default_value' =>
$owner->
isAnonymous() ? NULL :
$owner,
// A comment can be made anonymous by leaving this field empty therefore
// there is no need to list them in the autocomplete.
'#selection_settings' =>
['include_anonymous' => FALSE
],
'#title' =>
$this->
t('Authored by'
),
'#description' =>
$this->
t('Leave blank for %anonymous.',
['%anonymous' =>
$config->
get('anonymous'
)]),
'#access' =>
$is_admin,
];
// The name field is displayed when an anonymous user is adding a comment or
// when a user with the permission 'administer comments' is editing an
// existing comment from an anonymous user.