Registration: Added autocompletion information and fixed naming

This commit is contained in:
Igor Scheller 2020-11-14 01:51:03 +01:00 committed by msquare
parent 85baeb3a6b
commit c44d48a22a
2 changed files with 55 additions and 36 deletions

View File

@ -41,7 +41,7 @@ function guest_register()
$preName = '';
$dect = '';
$mobile = '';
$mail = '';
$email = '';
$pronoun = '';
$email_shiftinfo = false;
$email_by_human_allowed = false;
@ -71,8 +71,8 @@ function guest_register()
if ($request->hasPostData('submit')) {
$valid = true;
if ($request->has('nick')) {
$nickValidation = User_validate_Nick($request->input('nick'));
if ($request->has('username')) {
$nickValidation = User_validate_Nick($request->input('username'));
$nick = $nickValidation->getValue();
if (!$nickValidation->isValid()) {
@ -89,13 +89,13 @@ function guest_register()
$msg .= error(__('Please enter a nickname.'), true);
}
if ($request->has('mail') && strlen(strip_request_item('mail')) > 0) {
$mail = strip_request_item('mail');
if (!check_email($mail)) {
if ($request->has('email') && strlen(strip_request_item('email')) > 0) {
$email = strip_request_item('email');
if (!check_email($email)) {
$valid = false;
$msg .= error(__('E-mail address is not correct.'), true);
}
if (User::whereEmail($mail)->first()) {
if (User::whereEmail($email)->first()) {
$valid = false;
$msg .= error(__('E-mail address is already used by another user.'), true);
}
@ -180,7 +180,7 @@ function guest_register()
$user = new User([
'name' => $nick,
'password' => $password_hash,
'email' => $mail,
'email' => $email,
'api_key' => '',
'last_login_at' => null,
]);
@ -279,12 +279,25 @@ function guest_register()
div('col-md-6', [
div('row', [
div('col-sm-4', [
form_text('nick', __('Nick') . ' ' . entry_required(), $nick),
form_text(
'username',
__('Nick') . ' ' . entry_required(),
$nick,
false,
23,
'nickname'
),
form_info('',
__('Use up to 23 letters, numbers, connecting punctuations or spaces for your nickname.'))
]),
div('col-sm-8', [
form_email('mail', __('E-Mail') . ' ' . entry_required(), $mail),
form_email(
'email',
__('E-Mail') . ' ' . entry_required(),
$email,
false,
'email'
),
form_checkbox(
'email_shiftinfo',
__(
@ -300,6 +313,14 @@ function guest_register()
)
])
]),
div('row', [
div('col-sm-6', [
form_password('password', __('Password') . ' ' . entry_required())
]),
div('col-sm-6', [
form_password('password2', __('Confirm password') . ' ' . entry_required())
])
]),
div('row', [
$enable_planned_arrival ? div('col-sm-6', [
form_date(
@ -314,14 +335,6 @@ function guest_register()
$tshirt_sizes, $tshirt_size, __('Please select...')) : ''
])
]),
div('row', [
div('col-sm-6', [
form_password('password', __('Password') . ' ' . entry_required())
]),
div('col-sm-6', [
form_password('password2', __('Confirm password') . ' ' . entry_required())
])
]),
form_checkboxes(
'angel_types',
__('What do you want to do?') . sprintf(
@ -340,10 +353,10 @@ function guest_register()
div('col-md-6', [
div('row', [
$enable_dect ? div('col-sm-4', [
form_text('dect', __('DECT'), $dect)
form_text('dect', __('DECT'), $dect, false, 40, 'tel-local')
]) : '',
div($enable_dect ? 'col-sm-4' : 'col-sm-12', [
form_text('mobile', __('Mobile'), $mobile)
form_text('mobile', __('Mobile'), $mobile, false, null, 'tel-national')
]),
$enable_pronoun ? div('col-sm-4', [
form_text('pronoun', __('Pronoun'), $pronoun)
@ -351,10 +364,10 @@ function guest_register()
]),
$enable_user_name ? div('row', [
div('col-sm-6', [
form_text('prename', __('First name'), $preName)
form_text('prename', __('First name'), $preName, false, null, 'given-name')
]),
div('col-sm-6', [
form_text('lastname', __('Last name'), $lastName)
form_text('lastname', __('Last name'), $lastName, false, null, 'family-name')
])
]) : '',
form_info(entry_required() . ' = ' . __('Entry required!'))

View File

@ -71,7 +71,7 @@ function form_date($name, $label, $value, $start_date = '', $end_date = '')
return form_element($label, '
<div class="input-group date" id="' . $dom_id . '" data-min-date="' . $start_date . '" data-max-date="' . $end_date . '">
<input type="date" placeholder="YYYY-MM-DD" name="' . $name . '" class="form-control" value="' . htmlspecialchars($value) . '">'
<input type="date" placeholder="YYYY-MM-DD" name="' . $name . '" class="form-control" value="' . htmlspecialchars($value) . '" autocomplete="off">'
. '<span class="input-group-addon">' . glyph('th') . '</span>
</div>
', $dom_id);
@ -226,22 +226,25 @@ function form_submit($name, $label, $class = '', $wrapForm = true, $buttonType =
/**
* Rendert ein Formular-Textfeld
*
* @param string $name
* @param string $label
* @param string $value
* @param bool $disabled
* @param int $maxlength
* @param string $name
* @param string $label
* @param string $value
* @param bool $disabled
* @param int|null $maxlength
* @param string|null $autocomplete
*
* @return string
*/
function form_text($name, $label, $value, $disabled = false, $maxlength = null)
function form_text($name, $label, $value, $disabled = false, $maxlength = null, $autocomplete = null)
{
$disabled = $disabled ? ' disabled="disabled"' : '';
$maxlength = $maxlength ? ' maxlength=' . (int)$maxlength : '';
$autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : '';
return form_element(
$label,
'<input class="form-control" id="form_' . $name . '" type="text" name="' . $name
. '" value="' . htmlspecialchars($value) . '"' . $maxlength . $disabled . '/>',
. '" value="' . htmlspecialchars($value) . '"' . $maxlength . $disabled . $autocomplete . '/>',
'form_' . $name
);
}
@ -268,19 +271,22 @@ function form_text_placeholder($name, $placeholder, $value, $disabled = false)
/**
* Rendert ein Formular-Emailfeld
*
* @param string $name
* @param string $label
* @param string $value
* @param bool $disabled
* @param string $name
* @param string $label
* @param string $value
* @param bool $disabled
* @param string|null $autocomplete
*
* @return string
*/
function form_email($name, $label, $value, $disabled = false)
function form_email($name, $label, $value, $disabled = false, $autocomplete = null)
{
$disabled = $disabled ? ' disabled="disabled"' : '';
$autocomplete = $autocomplete ? ' autocomplete="' . $autocomplete . '"' : '';
return form_element(
$label,
'<input class="form-control" id="form_' . $name . '" type="email" name="' . $name . '" value="'
. htmlspecialchars($value) . '" ' . $disabled . '/>',
. htmlspecialchars($value) . '" ' . $disabled . $autocomplete . '/>',
'form_' . $name
);
}