0
cart.blade.php嵌套的HTML formBuilder與Laravel
@extends('master')
@section('content')
<div class="container">
@if(Cart::isEmpty())
<b>The card is empty</b> <a href="/products">Shopping now</a>
@else
<table class="table table-condensed table-bordered">
<thead>
<tr>
<th>item id</th>
....
</tr>
</thead>
<tbody>
{!! Form::open(["url"=>"/pay"]) !!}
<?php $i = 0; $totalCart_price = 0; ?>
@foreach($cart_total_items as $item)
<tr>
<td>{{ $item['id'] }}</td>
....
<td>
{!! Form::open(["url"=>"/my-cart/".$item['id'], "method"=>"DELETE", "style"=>"display: inline"]) !!}
<button type="submit" class="btn btn-danger" aria-label="Left Align">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</button>
{!! Form::close() !!}
</td>
</tr>
<?php $i++; $totalCart_price += Cart::get($item['id'])->getPriceSum(); ?>
@endforeach
</tbody>
</table>
<b>Total price: ${{ $totalCart_price }} {{ Form::hidden("total_price", $totalCart_price) }}</b>
<br><br>
{!! Form::submit('check out (paypal)', ["class"=>"btn btn-primary"]) !!}
{!! Form::close() !!}
<a href="/my-cart/clear" class="btn btn-danger">Clear cart</a>
@endif
</div>
@stop
問題:我可以刪除任何項目,但點擊時檢查出什麼也不會發生,但是當我刪除clear item form
,成功退房運行。
我想運行兩個操作,我該如何解決它?
謝謝
使用AJAX偉大的想法,但沒有辦法使兩個操作之間的重疊? –
不,但你可以檢查我的答案。我認爲你可以實現你想要的而不會重疊表格。 – jaysingkar
如果我錯了,請糾正我。答案是基於我在代碼中觀察到的。我已經分離了兩種形式而不會失去你想要實現的功能。 – jaysingkar