Commit ac40edf3 authored by Dries's avatar Dries

Issue #1866978 by sun: Leverage new #input facility of #type 'item' for author...

Issue #1866978 by sun: Leverage new #input facility of #type 'item' for author name in comment form.
parent 3e478b03
...@@ -76,38 +76,23 @@ public function form(array $form, array &$form_state, EntityInterface $comment) ...@@ -76,38 +76,23 @@ public function form(array $form, array &$form_state, EntityInterface $comment)
} }
// Add the author name field depending on the current user. // Add the author name field depending on the current user.
$form['author']['name'] = array(
'#type' => 'textfield',
'#title' => t('Your name'),
'#default_value' => $author,
'#required' => (!$user->uid && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
'#maxlength' => 60,
'#size' => 30,
);
if ($is_admin) { if ($is_admin) {
$form['author']['name'] = array( $form['author']['name']['#title'] = t('Authored by');
'#type' => 'textfield', $form['author']['name']['#description'] = t('Leave blank for %anonymous.', array('%anonymous' => config('user.settings')->get('anonymous')));
'#title' => t('Authored by'), $form['author']['name']['#autocomplete_path'] = 'user/autocomplete';
'#default_value' => $author,
'#maxlength' => 60,
'#size' => 30,
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => config('user.settings')->get('anonymous'))),
'#autocomplete_path' => 'user/autocomplete',
);
} }
elseif ($user->uid) { elseif ($user->uid) {
$form['author']['_author'] = array( $form['author']['name']['#type'] = 'item';
'#type' => 'item', $form['author']['name']['#value'] = $form['author']['name']['#default_value'];
'#title' => t('Your name'), $form['author']['name']['#markup'] = theme('username', array('account' => $user));
'#markup' => theme('username', array('account' => $user)),
);
$form['author']['name'] = array(
'#type' => 'value',
'#value' => $author,
);
}
else {
$form['author']['name'] = array(
'#type' => 'textfield',
'#title' => t('Your name'),
'#default_value' => $author,
'#required' => (!$user->uid && $anonymous_contact == COMMENT_ANONYMOUS_MUST_CONTACT),
'#maxlength' => 60,
'#size' => 30,
);
} }
// Add author e-mail and homepage fields depending on the current user. // Add author e-mail and homepage fields depending on the current user.
......
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