Also check if required fields are empty

2022-03-24
Luca 3 years ago
parent 1ba5cd9fe8
commit 9def5d689e

@ -92,30 +92,22 @@ function guest_register()
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
$valid = true; $valid = true;
if ($request->has('prename')) { if (!$request->has('prename') || empty($preName = strip_request_item('prename'))) {
$preName = strip_request_item('prename');
} else {
$valid = false; $valid = false;
$msg .= error(__('Please enter your first name.'), true); $msg .= error(__('Please enter your first name.'), true);
} }
if ($request->has('lastname')) { if (!$request->has('lastname') || empty($lastName = strip_request_item('lastname'))) {
$lastName = strip_request_item('lastname');
} else {
$valid = false; $valid = false;
$msg .= error(__('Please enter your last name.'), true); $msg .= error(__('Please enter your last name.'), true);
} }
if ($request->has('mobile')) { if (!$request->has('mobile') || empty($mobile = strip_request_item('mobile'))) {
$mobile = strip_request_item('mobile');
if (User::whereName($mobile)->count() > 0) {
$valid = false;
$msg .= error(__('This mobile number is already in use.'), true);
}
} else {
$valid = false; $valid = false;
$msg .= error(__('Please enter your mobile number.'), true); $msg .= error(__('Please enter your mobile number.'), true);
} else if (User::whereName($mobile)->count() > 0) {
$valid = false;
$msg .= error(__('This mobile number is already in use.'), true);
} }
if ($request->has('mobile_consent')) { if ($request->has('mobile_consent')) {
@ -314,6 +306,10 @@ function guest_register()
$lastName = $form_data['last_name']; $lastName = $form_data['last_name'];
} }
if (!$mobile && !empty($form_data['phone_number'])) {
$mobile = $form_data['phone_number'];
}
return page_with_title(register_title(), [ return page_with_title(register_title(), [
form_element('', __('By completing this form you\'re registering as a Chaos-Angel. This script will create you an account in the angel task scheduler.')), form_element('', __('By completing this form you\'re registering as a Chaos-Angel. This script will create you an account in the angel task scheduler.')),
form_element('', entry_required() . ' = ' . __('Entry required!')), form_element('', entry_required() . ' = ' . __('Entry required!')),

Loading…
Cancel
Save