Last active
November 6, 2024 05:25
-
-
Save nafiesl/fc851d38f9c8ee79e5e73facedb2ac03 to your computer and use it in GitHub Desktop.
Laravel Select Dropdown Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="form-group"> | |
<label for="model_id" class="control-label">Model Unit</label> | |
<select name="model_id" id="model_id" class="form-control{{ $errors->has('model_id') ? ' is-invalid' : '' }}" required> | |
<option value="">-- Pilih Model --</option> | |
@foreach ($unitModels as $unitModel) | |
<option value="{{ $unitModel->id }}" {{ $unitModel->id == old('model_id', request('model_id')) ? 'selected' : '' }}> | |
{{ $unitModel->code }} - {{ $unitModel->name }} | |
</option> | |
@endforeach | |
</select> | |
{!! $errors->first('model_id', '<span class="invalid-feedback" role="alert">:message</span>') !!} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use App\UnitType; | |
use App\UnitModel; | |
class UnitTypeController extends Controller | |
{ | |
public function edit(UnitType $unitType) | |
{ | |
$unitModels = UnitModel::all(); | |
return view('unit_types.edit', compact('unitType', 'unitModels')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment