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

8.0.x
Dries 2013-02-01 15:37:04 -05:00
parent 3e478b0362
commit ac40edf3fd
1 changed files with 14 additions and 29 deletions

View File

@ -76,38 +76,23 @@ class CommentFormController extends EntityFormControllerNG {
} }
// 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.