如何在Laravel

时间:2018-03-16 15:43:09

标签: php laravel

对于我的网站,当点击此特定页面时,我希望使用数据库中的数据填充表单。以下是表单的代码:

<form class="form-horizontal" role="form" method="post" action="{{url('/company-profile/update')}}">
        {{ csrf_field() }}
        @foreach($getAllDetails as $list)
            <div class="form-group">
                <div class="col-sm-10">
                <label for="companyname" class="control-label">Company Name</label>  
                <input type="text" class="form-control" id="companyname" name="companyname" placeholder="Enter Company Name" value={{$list->companyName}}>
                </div>
            </div>
           <div class="form-group">
                <div class="col-xs-5 col-sm-4 col-md-3">
                    <label for="shortCode" class="control-label">Short Code</label>
                    <input class="form-control" id="shortCode" name="shortCode" placeholder="Short Code" value={{$list->shortCode}}>
                </div>
                <div class="col-xs-7 col-sm-6 col-md-7">
                    <label for="telnum" class="control-label">Telephone Number</label>
                    <input type="tel" class="form-control" id="telnum" name="telnum" placeholder="Tel. number" value={{$list->phoneNo}}>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-10">
                    <label for="emailid" class="control-label">Email</label>
                    <input type="email" class="form-control" id="emailid" name="emailid" placeholder="Email" value={{$list->emailAddress}}>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-10">
                    <label for="logoPath" class="control-label">Logo Path</label>
                    <input type="" class="form-control" id="logoPath" name="logoPath" placeholder="Enter Logo Path" value={{$list->logoPath}}>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-10">
                    <label for="feedback" class="control-label">Contact Address</label>
                    <textarea class="form-control" id="address" name="address" rows="2" value={{$list->contactAddress}}></textarea>
                </div>
            </div>
           @endforeach
             <div class="form-group">
                <div class="col-sm-10">
                    <button type="submit" class="btn btn-success">Submit</button>
                </div>
            </div> 
        </form>

这个问题是:

例如,如果我想获取公司名称{{$list->companyName}},则仅显示第一个单词。例如,如果该公司的名称是国家电影协会,则仅显示国家电影。

以下是控制器中我的索引函数的代码:

public function index()
{
    $data['getAllDetails']= DB::table('tblcompany')->get();
    return view('companyProfile.companyProfile', $data);
}

1 个答案:

答案 0 :(得分:1)

更改

  

值= {{$列表 - &GT; your_field}}   到

value="{{$list->your_field}}"