I'm trying to create registration form in laravel but with my custom input fields, I've changed the 'register.bladed.php' to change the 'view'.
The default registration form was containing name , email , password, confirm Password.
I added two new input fields i.e gender and date-of-birth.
I made changes to the create_users_table.php with above two new input fields and then migrate that which results into the following table structure.
Now when I try to register any user it gives me the following error
SQLSTATE[HY000]: General error: 1364 Field 'gender' doesn't have a default value (SQL: insert into
users(name,password,updated_at,created_at) values (abc, [email protected], $2y$10$wGLT0qsJ3EmSSa4vzTj0sOop6eRvtPShg9.aEZ6wJFJY8OdHMsrBO, 2019-06-07 15:55:08, 2019-06-07 15:55:08))
I think I want to change something where the form is submitting, but there are two functions where the form is submitting i.e route register
1.validator
2. create
I don't know what to do with that ?
What changes do I need to make to have the new input new input fields working, and in future which things should I do to make custom input fields working correctly .
The name for date-of-birthis dob given as:
<div class="col-md-6">
<input id="dob" type="date" class="form-control @error('email') is-invalid @enderror" name="dob" value="{{ old('dob') }}" required autocomplete="dob">
@error('dob')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
for gender it is :
<div class="col-md-6">
<select id="" class=" form-control" name = 'gender' required>
<option value="Male">Male</option>
<option value="Fe Male">Fe Male</option>
</select>
@error('gender')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
I've used the same names in RegisterController.php.
the table looks like this :
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email');
$table->date('dd/mm/yy')
$table->string('gender');
$table->timestamps();
});
}
I've made some manual changes to the table in my phpmyadmin according to the above structure of the table, without php artisan migrate.
May be something that is obvious I'm asking about , but I'm new totally new to laravel.
Thank you so much.