Ayman Hussein
Ayman Hussein

Reputation: 3857

customize registration form in laravel 5

I am, newbie on Laravel 5, I need to customize registration form in laraverl 5 so i added some extra fields such as fullname, company, country and mobile number.

I added them successfully to resources/views/auth/register.blade.php see image: enter image description here

and updated Services/Register.php file to save new fields to users table and that's work fine.

my problem now is: i need country field is selected list not textfield.

I have table in database 'countries' and I have model 'Country', so how can it build selected list and fill it with countries from countries table.

Upvotes: 2

Views: 3013

Answers (2)

Raviraj Chauhan
Raviraj Chauhan

Reputation: 653

Just add:

{!! Form::select('country', App\Country::lists('name', 'id'), null, ['class'=> 'form-control']) !!}

This will list all the countries to select tag from the database table.

Replace name to column name assigned for country name.

Note: install "illuminate/html" package to use Form facade.

EDIT: the previous code was a little wrong and it caused errors. Now it is fixed.

Upvotes: 3

Kingsley
Kingsley

Reputation: 1051

The selected answer is missing a 2nd :

It should be:

{!! Form::select('user_type_id', App\UserType::lists('name', 'id'), null, ['class'=> 'form-control']) !!}

Upvotes: 1

Related Questions