'How can I prevent new line when I am using loop and form?
How can I prevent new line when I am using loop and form.I have tried style="display: inline-block;" but it didn't work. I would want buttons to be in one line ,next to each other.
<div>
@foreach (range(1, 12) as $item)
@if(App\Models\Seats::find($item))
<form method="post" action="{{ route('seats.destroy', $item) }}">
@csrf
@method('delete')
<input type="hidden" name="id" value="{{ $item }}"/>
<input type="hidden" name="row_seats" value="4"/>
<input type="hidden" name="seat_id" value="{{ $item }}"/>
<button type="submit" style="margin-left:10px; width:60px;" class="btn btn-danger">{{$item}}</button>
</form>
@else
<form method="post" action="/seats">
@csrf
<input type="hidden" name="id" value="{{ $item }}"/>
<input type="hidden" name="row_seats" value="4"/>
<input type="hidden" name="seat_id" value="{{ $item }}"/>
<button type="submit" style="width:60px; margin-left:10px;" class="btn btn-success">{{ $item}}</button>
</form>
@endif
@endforeach
</div>
Solution 1:[1]
I found decision of the problem this is my code if someone have the same problem. I used div with with display:flex
<div style="margin-left:90px;" class="row pt-1 pb-1 ">
<div style="display: flex;">
4 ???
@foreach (range(1, 12) as $item)
@if(App\Models\Seats::find($item))
<form style="display: inline-block;" method="post" action="{{ route('seats.destroy', $item) }}">
@csrf
@method('delete')
<!-- <input type="hidden" name="user_id" value="{{Auth::user()->id}}"/> -->
<input type="hidden" name="id" value="{{ $item }}"/>
<input type="hidden" name="row_seats" value="4"/>
<input type="hidden" name="seat_id" value="{{ $item }}"/>
<button type="submit" style="margin-left:10px; width:80px; display:inline;" class="btn btn-danger">{{$item}}</button>
</form>
@else
<form style="display: inline;" method="post" action="/seats">
@csrf
<!-- <input type="hidden" name="user_id" value="{{Auth::user()->id}}"/> -->
<input type="hidden" name="id" value="{{ $item }}"/>
<input type="hidden" name="row_seats" value="4"/>
<input type="hidden" name="seat_id" value="{{ $item }}"/>
<button type="submit" style="width:80px; margin-left:10px;" class="btn btn-success">{{ $item}}</button>
</form>
@endif
@endforeach
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pokebol |
