SA__ SA__ - 9 months ago 67
PHP Question

Laravel Option Select - Default Issue

Here is my Select Box, Here All Company will be loaded,

But i want to display the Particular company as default selected which i have it in session.

Here is my Code

$sessioncompany = 'ABCcompany'
$comp[''] = 'Company';
@foreach($company_list as $row)
$comp[$row->CompanyID] = $row->CompanyName;
{{ Form::select('CompanyID', $comp, '', array('id' => 'seCompanyID')); }}

What i tried is

{{ Form::select('CompanyID', $comp, '', array('id' => 'seCompanyID'), array(id=>$sessioncompany)); }}

But i ended with failure

What is the mistake i am doing and How can i fix that ?

Note : I want it in the native laravel method

$selectedId = ... // get the id from the session
{{ Form::select('CompanyID', $comp, array($selectedId), array('id' => 'seCompanyID')) }}