diff --git a/CHANGELOG.md b/CHANGELOG.md index ee90cef..cea4dcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-form-components` will be documented in this file +## 3.2.0 - 2021-11-01 + +- Support for `select` placeholder + ## 3.1.0 - 2021-11-01 - Support for Date Casting diff --git a/README.md b/README.md index 7e43670..912ec99 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,23 @@ If you want a select element where multiple options can be selected, add the `mu ``` +You may add a `placeholder` attribute to the select element. This will prepend a disabled option. + +This feature was added in v3.2.0. If you're upgrading from a previous version *and* you published the Blade views, you should republish them *or* update them manually. + +```blade + +``` + +Rendered HTML: + +```html + +``` + #### Using Eloquent relationships This package has built-in support for `BelongsToMany`, `MorphMany`, and `MorphToMany` relationships. To utilize this feature, you must add both the `multiple` and `many-relation` attribute to the select element. diff --git a/resources/views/bootstrap-4/form-select.blade.php b/resources/views/bootstrap-4/form-select.blade.php index d0ab123..57206e1 100644 --- a/resources/views/bootstrap-4/form-select.blade.php +++ b/resources/views/bootstrap-4/form-select.blade.php @@ -12,11 +12,22 @@ multiple @endif + @if($placeholder) + placeholder="{{ $placeholder }}" + @endif + @if($label && !$attributes->get('id')) id="{{ $id() }}" @endif {!! $attributes->merge(['class' => 'form-control ' . ($hasError($name) ? 'is-invalid' : '')]) !!}> + + @if($placeholder) + + @endif + @forelse($options as $key => $option) + @endif + @forelse($options as $key => $option) + @endif + @forelse($options as $key => $option) + @endif + @forelse($options as $key => $option)