Reputation: 89
I want to make a loop like clockwork and this is the loop code I created
<?php for ($i = 1; $i <= 24; $i++) ?>
After that I want to display the result of a iteration into the list by using Forms & HTML laravel 4.2
<?php echo Form::select('value['.$data['sale_payment_deadline']->id.']', [$i => "$i Hour"], $data['sale_payment_deadline']->value, array('class'=>'form-control','autocomplete'=>'off'));?>
But unfortunately it does not get all the looping I've made before, should i get the loop 1-24, but what happens is i only get 25 how to handle it? thanks for the help replied
Upvotes: 2
Views: 99
Reputation: 499
<?php
$hours = array();
for ($i = 1; $i <= 24; $i++) {
array_push($hours, $i + " Hour");
}
echo Form::select(
'value['.$data['sale_payment_deadline']->id.']',
[$i => "$i Hour"],
$data['sale_payment_deadline']->value,
array('class'=>'form-control','autocomplete'=>'off')
);
?>
Edit:
After looking at the Laravel documentation you need to pass an array into the Form creation, which means you have to construct it before-hand.
Example: {{ Form::select('age', ['Under 18', '19 to 30', 'Over 30']) }}
http://laravel-recipes.com/recipes/163/creating-a-select-box-field
You might have to put the rest of the data into an array and iterate through it when you create the dropdown box.
Upvotes: 1
Reputation: 1604
<?php
for ($i = 1; $i <= 24; $i++) {
echo Form::select('value['.$data['sale_payment_deadline']->id.']',
[$i => "$i Hour"],
$data['sale_payment_deadline']->value,
array('class'=>'form-control','autocomplete'=>'off')
);
}
?>
Upvotes: 0