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