0

For my website, when this particular page is clicked I want the form to be populated with data from the database. Here is the code for the form:

<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>

This issue is:

For example, if I want to fetch the company name {{$list->companyName}} only the first word gets displayed. For example, If the company's name is National Film Institute, only National gets displayed.

Here is code the for my index function in the controller:

public function index()
{
    $data['getAllDetails']= DB::table('tblcompany')->get();
    return view('companyProfile.companyProfile', $data);
}
2
  • Can you pass $data to your view and read it with foreach($getAllDetails as $list)? Wondering if this is a typo or some magic PHP capability I didn't know about Commented Mar 16, 2018 at 15:45
  • Can you please show output of $getAllDetails? Commented Mar 16, 2018 at 15:47

1 Answer 1

1

Change

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

value="{{$list->your_field}}"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.