Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 form select ID attribute not being added

Tags:

php

laravel

I'm using a Laravel form attribute as shown below:

{!! 
Form::select('industry', $industries,  array('class' =>
            'form-control', 'style'=>' resize:vertical; ',
            'id' => 'industryId')) 
!!}

The problem is I'm unable to get id 'indusrtyId'. The HTML output is:

<select name="industry"> 
   <option value="1">Accounting</option>
   <option value="2">Airlines/Aviation</option>
</select>
like image 522
Talib Hussain Avatar asked Jan 07 '23 08:01

Talib Hussain


1 Answers

Try to add null as third parameter:

{!! Form::select('industry', $industries, null, array('class' => 'form-control', 'style'=>' resize:vertical; ', 'id' => 'industryId')) !!}

Third parameter is used to set selected element. Array with HTML parameters should be fourth parameter in Form::select clause.

like image 85
Alexey Mezenin Avatar answered Jan 15 '23 19:01

Alexey Mezenin