PlanRadioOptions
This commit is contained in:
1 parent
b00af65e72
commit
8463f50f6b
4 files changed
+72
-8
No files matched your search
@@ -19,13 +19,16 @@ class KontoForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
ImageRadioGroup::make('plan_id')
|
||||
->animation(true)
|
||||
->disk('promotion')
|
||||
->label('Plan')
|
||||
->required()
|
||||
->columnSpanFull()
|
||||
->options(fn () => Plan::pluck('promotion', 'id')->toArray()),
|
||||
|
||||
// Radio Cards with default features
|
||||
|
||||
// ImageRadioGroup::make('plan_id')
|
||||
// ->animation(true)
|
||||
// ->disk('promotion')
|
||||
// ->label('Plan')
|
||||
// ->required()
|
||||
// ->columnSpanFull()
|
||||
// ->options(fn () => Plan::pluck('promotion', 'id')->toArray()),
|
||||
Section::make('Firma')
|
||||
->inlineLabel()
|
||||
->schema([
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Kontos\Tables;
|
||||
|
||||
use App\Forms\Components\PlanRadioGroup;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
@@ -42,7 +43,21 @@ class KontosTable
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton()->color('gray'),
|
||||
Action::make('Laden')
|
||||
Action::make('Konto')
|
||||
->iconButton()
|
||||
->color('gray')
|
||||
->icon('lucide-plane-takeoff')
|
||||
->schema([
|
||||
PlanRadioGroup::make('plan_id')
|
||||
->label('Plan')
|
||||
->options(fn () => Plan::pluck('name', 'id')->toArray()),
|
||||
// ->options([
|
||||
// '1' => 'Basic',
|
||||
// '2' => 'Smart',
|
||||
// '3' => 'Premium',
|
||||
// ]),
|
||||
]),
|
||||
Action::make('Bezahlen')
|
||||
->iconButton()
|
||||
->color('gray')
|
||||
->icon('heroicon-o-credit-card')
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Components;
|
||||
|
||||
use Filament\Forms\Components\Field;
|
||||
|
||||
class PlanRadioGroup extends Field
|
||||
{
|
||||
protected string $view = 'forms.components.custom-radio-group';
|
||||
|
||||
protected array $options = []; // Property to store options
|
||||
|
||||
public function options(array $options): static
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->evaluate($this->options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
@php
|
||||
$state = $getState(); // Get the current state of the radio group
|
||||
$options = $getOptions(); // Assuming you have a method to get options in your component
|
||||
$name = $getName(); // Get the field name for the input
|
||||
@endphp
|
||||
|
||||
<div>
|
||||
@foreach ($options as $value => $label)
|
||||
<label class="cursor-pointer">
|
||||
<div
|
||||
@if ($state === $value) class="flex border border-red-500 p-2" @else class="flex gap-3 border border-amber-500 p-12" @endif>
|
||||
<input type="radio" name="{{ $name }}" value="{{ $value }}"
|
||||
@if ($state === $value) checked @endif {{ $attributes->merge(['class' => 'form-radio']) }}
|
||||
wire:model="{{ $name }}">
|
||||
<h1 class="scroll-m-20 text-3xl md:text-4xl font-black tracking-tight lg:text-5xl text-shadow-sm">
|
||||
{{ $label }}
|
||||
</h1>
|
||||
</div>
|
||||
</label>
|
||||
<br>
|
||||
@endforeach
|
||||
</div>
|
||||
Reference in new issue
Block a user