Situation:
In the models I have user.php, which handles all the checks regarding adding a user to the website.
This is (part of) the code:
public static $add_rules = array(
'last_name' => 'required',
'first_name' => 'required',
'email' => 'required|unique:users,email',
'username' => 'required|alpha_num|min: 5|unique:users,username',
'password' => 'required|min: 4|same:password_confirmation',
'password_confirmation' => 'required',
'user_role' => 'required|not_in:-- Choose User Type --'
);
user_role is the id of the dropdown list, see here:
<select name="user_type_id" class="form-control" id="user_role">
<option value="0">-- Choose User Type --</option>
@if(Session::get("user_type") == "superuser")
{
@foreach($user_types as $ut)
<option value="{{$ut['id']}}">
{{ ucwords($ut["user_type"]) }}
</option>
@endforeach
}
@else{
<option value="Regular">Regular</option>
}@endif
</select>
Basically, what happens is that the drop-down list is populated with user types, whatever they are. But he always has the first "option" -- Choose User Type --.
Problem:
The problem is that the user can go with this option and add the user. I have javascript code that blocks this and displays an error message in a popup window, but it is ugly and inconsistent with the rest of the website error messages.
. , -, -- Choose User Type -- .
:
not_in , .
?
.