我想选择一个名称并自动以表单形式输出其属性,如何自动显示其属性?
<select id="suppliers_name" name="suppliers_name" class="form-control" data-plugin="select2">
@foreach ($supplier as $suppliers)
<option value="{{$suppliers->name}}">{{$suppliers->supplier_name}}</option>
@endforeach
</select>
</div>
</div>
<div class="form-group row">
<label for="Supplier/s Address" class="col-sm-2 col-form-label">Suppler/s Address:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="sup_address" name="sup_address" placeholder="Supplier's Address" value="{{$suppliers->supplier_address}}" >
</div>
</div>
<div class="form-group row">
<label for="Contact Person" class="col-sm-2 col-form-label">Contact Person:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="con_person" name="con_person" placeholder="Contact Person Name" value="{{$suppliers->contact_person_name}}" disabled>
</div>
</div>
我可以选择供应商名称,但无法显示其属性。
这是控制器:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Po;
use App\Supplier;
class PoController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$po = Po::All()->name();
return view('/po.manage-po', compact('po'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$supplier = Supplier::All();
return view('/po.add-po', compact('supplier'));
}