gwapo
gwapo

Reputation: 208

Convert select option into laravel format

I just want to ask on how to convert this to laravel like the {!! form something something !!}}.

The first select option is for gender that have the options of male and female.

While the second select option has the options of the Company table but i dont want to display the first id of the company.

Can you help me convert this to laravel format of select?

<div class="col-md-2">
    <div class="form-group-sm">
        <select class="form-control form-control-sm" id="gender" name="gender">
            <option selected  disabled><small>Gender</small></option>
            <option>All</option>
            <option value="Male">Male</option>
            <option value="Female">Female</option>
        </select>
    </div>
</div>
<div class="col-md-2">
    <div class="col-md-2">
        <div class="form-group-sm"> 
            <select class="form-control form-control-sm" id="company" name="company">
                <option selected  disabled>Company</option>
                @foreach ($companies as $company)
                    @if (($company->id)=="1")
                    <option>All</option>
                    @else
                    <option value="{{ $company->id }}">{{ $company->name }}</option>
                    @endif
                @endforeach
            </select>
        </div>
    </div>
</div>

Upvotes: 0

Views: 150

Answers (2)

Saurabh Mistry
Saurabh Mistry

Reputation: 13669

try this :

 <select class="form-control form-control-sm" id="company" name="company">
 <option selected  disabled>Company</option>
    @foreach ($companies as $company)
          @if ($company->id!=1)
             <option value="{{ $company->id }}">{{ $company->name }}</option>
          @endif
    @endforeach
</select>

Upvotes: 0

Saly
Saly

Reputation: 1496

You should use this package laravelcollective/html to convert your form and html. https://laravelcollective.com/docs/5.4/html

Upvotes: 1

Related Questions