我的表单有一个选择框,我需要将选择框选择的值传递给laravel资源show()
方法,以显示所选值的特定详细信息。
<form action="{{ action('supplierController@show') }}" method="POST" class="form" role="form">
<div class="form-group">
<label for="inputEmail3" control-label">company name</label>
<select class="form-control js-example-basic-single" name="seller">
<option value=""></option>
@foreach($supplierlist as $supplier)
<option value="{{ $supplier->company_name }}">{{ $supplier->company_name }}</option>
@endforeach
</select>
</div>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<button type="submit" class="btn btn-primary">GO</button>
</form>
selectbox的值来自数据库,所以我如何将selectbox的选定值的值传递给我的控制器。
答案 0 :(得分:1)
<div class="ui-grid ui-grid-responsive ui-fluid" *ngIf="saveObject">
<div *ngFor="let f of fields; let i = index">
<div *ngIf="i % 2 === 1 && i < fields?.length" class="ui-grid-row">
<div *ngFor="let field of [fields[i-1],fields[i]]">
<div class="ui-grid-col-3 field-label"><label for="attribute">{{field.key}}</label></div>
<div class="ui-grid-col-3">
<p-checkbox *ngIf="booleanFields.indexOf(field.key) !== -1" binary="true" [(ngModel)]="saveObject[field.key]"></p-checkbox>
<p-calendar *ngIf="dateFields.indexOf(field.key) !== -1" [(ngModel)]="saveObject[field.key]" dateFormat="yy-mm-dd" [showIcon]="true"></p-calendar>
<input *ngIf="(booleanFields.indexOf(field.key) === -1) && (dateFields.indexOf(field.key) === -1)" pInputText id="attribute" [(ngModel)]="saveObject[field.key]"/>
</div>
</div>
</div>
<div *ngIf="fields?.length % 2 === 1 && i === fields?.length - 1">
<div *ngFor="let field of [fields[i]]">
<div class="ui-grid-col-6 field-label"><label for="attributeEnd">{{field.key}}</label></div>
<div class="ui-grid-col-6">
<p-checkbox *ngIf="booleanFields.indexOf(field.key) !== -1" binary="true" [(ngModel)]="saveObject[field.key]"></p-checkbox>
<p-calendar *ngIf="dateFields.indexOf(field.key) !== -1" [(ngModel)]="saveObject[field.key]" dateFormat="yy-mm-dd" [showIcon]="true"></p-calendar>
<input *ngIf="(booleanFields.indexOf(field.key) === -1) && (dateFields.indexOf(field.key) === -1)" pInputText id="attributeEnd" [(ngModel)]="saveObject[field.key]"/>
</div>
</div>
</div>
</div>
</div>
应该有一个名称,然后您可以使用<select>
获取值。
答案 1 :(得分:0)
请尝试以下方法 在您的视图中,部分包括以下内容,请考虑$ categories包含选项中的类别
{!! Form :: select(&#39; category&#39;,array(&#39; 0&#39; =&gt;&#39;选择类别&#39;)+ $ categories,[&#39; class&#39; =&gt;&#39;中m-wrap&#39;])!!}
在您的控制器中包含
$category = $request->get('category');