简体   繁体   中英

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: 在此处输入图片说明

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.

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.

The selected answer is missing a 2nd :

It should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM