Skip to content

Commit bfb1674

Browse files
committed
Added Select Feature and Fix Upload File
1 parent 489d3d2 commit bfb1674

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected static function boot(): void
7070

7171
- [X] Text Field
7272
- [X] Upload Field
73-
- [ ] Select Field
73+
- [X] Select Field
7474
- [ ] Checkbox Field
7575
- [ ] Radio ‌Button Field
7676
- [ ] Tabs Field

src/Resources/Views/components/ImageUploadMetabox.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div>
22
<div class="imageUploadMetabox">
3-
<label for="imgField">Upload Image</label>
4-
<input type="file" class="form-control" name="img_field" id="imgField" accept="image/*">
3+
<label for="{{ $name }}">Upload Image</label>
4+
<input type="file" name="{{ $name }}" id="{{ $name }}" accept="image/*">
55

66
@if ($value)
77
<div class="imagePreview">
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div>
2+
<div class="SelectMetabox">
3+
<label for="{{ $name }}">{{ ucfirst(str_replace('_', ' ', $name)) }}</label>
4+
<select name="{{ $name }}" id="{{ $name }}">
5+
@foreach ($options as $value => $label)
6+
<option value="{{ $value }}" {{ $selected == $value ? 'selected' : '' }}>{{ $label }}</option>
7+
@endforeach
8+
</select>
9+
</div>
10+
<style>
11+
.SelectMetabox {
12+
margin-bottom: 20px;
13+
}
14+
15+
.SelectMetabox label {
16+
display: block;
17+
margin-bottom: 5px;
18+
font-weight: bold;
19+
}
20+
21+
.SelectMetabox select {
22+
width: 100%;
23+
padding: 8px;
24+
border: 1px solid #ccc;
25+
border-radius: 4px;
26+
font-size: 14px;
27+
}
28+
</style>
29+
</div>

src/View/Components/SelectMetabox.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Rayiumir\LaravelMetabox\View\Components;
4+
5+
use Closure;
6+
use Illuminate\Contracts\View\View;
7+
use Illuminate\View\Component;
8+
9+
class SelectMetabox extends Component
10+
{
11+
public $name;
12+
public $options;
13+
public $selected;
14+
/**
15+
* Create a new component instance.
16+
*/
17+
public function __construct($name, $options, $selected = null)
18+
{
19+
$this->name = $name;
20+
$this->options = $options;
21+
$this->selected = $selected;
22+
23+
}
24+
25+
/**
26+
* Get the view / contents that represent the component.
27+
*/
28+
public function render(): View|Closure|string
29+
{
30+
return view('components.SelectMetabox');
31+
}
32+
}

0 commit comments

Comments
 (0)