ALI ISMAEEL
ALI ISMAEEL

Reputation: 115

Generation of Dynamic Dropdown based on number of rows in laravel

I am trying to make a dynamic drop down menu. For example, if i have 3 rows, I want the drop down values are 1 , 2 , 3 and so on.

I have tried the code below, it works shows dynamic list but there is a '0' in the list I can't understand why

In my controller (this will get the S_Rank column which is exactly what i need to list in my drop down menu)

$ranks = array();
foreach($applications as $application) {
$ranks[] = $application->S_Rank;}

this is my view

{{Form::select('Abstract_Status_ID' ,[$ranks], $application->S_ID, ['class' => 'form-control', 'placeholder' =>$application->S_Rank] )}} 

the result where it shows the weird '0'

http://prntscr.com/nlwihy

Upvotes: 0

Views: 84

Answers (1)

Dan
Dan

Reputation: 5358

You don't need to put the $ranks array into another array.

{{ Form::select('Abstract_Status_ID', $ranks, $application->S_ID, ['class' => 'form-control', 'placeholder' => $application->S_Rank]) }}

Upvotes: 2

Related Questions