|
3 | 3 | namespace App\Filament\Pages\Settings; |
4 | 4 |
|
5 | 5 | use App\Settings\InfluxDbSettings; |
| 6 | +use Closure; |
6 | 7 | use Filament\Forms\Components\Grid; |
7 | 8 | use Filament\Forms\Components\Section; |
8 | 9 | use Filament\Forms\Components\TextInput; |
@@ -39,27 +40,38 @@ protected function getFormSchema(): array |
39 | 40 | ->schema([ |
40 | 41 | Toggle::make('v2_enabled') |
41 | 42 | ->label('Enable') |
| 43 | + ->reactive() |
42 | 44 | ->columnSpan(2), |
43 | | - TextInput::make('v2_url') |
44 | | - ->label('URL') |
45 | | - ->placeholder('http://your-influxdb-instance') |
46 | | - ->maxLength(255) |
47 | | - ->columnSpan(['md' => 2]), |
48 | | - TextInput::make('v2_org') |
49 | | - ->label('Org') |
50 | | - ->maxLength(255) |
51 | | - ->columnSpan(1), |
52 | | - TextInput::make('v2_bucket') |
53 | | - ->placeholder('speedtest-tracker') |
54 | | - ->label('Bucket') |
55 | | - ->maxLength(255) |
56 | | - ->columnSpan(1), |
57 | | - TextInput::make('v2_token') |
58 | | - ->label('Token') |
59 | | - ->maxLength(255) |
60 | | - ->password() |
61 | | - ->disableAutocomplete() |
62 | | - ->columnSpan(['md' => 2]), |
| 45 | + Grid::make([ |
| 46 | + 'default' => 1, |
| 47 | + ]) |
| 48 | + ->hidden(fn (Closure $get) => $get('v2_enabled') !== true) |
| 49 | + ->schema([ |
| 50 | + TextInput::make('v2_url') |
| 51 | + ->label('URL') |
| 52 | + ->placeholder('http://your-influxdb-instance') |
| 53 | + ->maxLength(255) |
| 54 | + ->required(fn (Closure $get) => $get('v2_enabled') == true) |
| 55 | + ->columnSpan(['md' => 2]), |
| 56 | + TextInput::make('v2_org') |
| 57 | + ->label('Org') |
| 58 | + ->maxLength(255) |
| 59 | + ->required(fn (Closure $get) => $get('v2_enabled') == true) |
| 60 | + ->columnSpan(1), |
| 61 | + TextInput::make('v2_bucket') |
| 62 | + ->placeholder('speedtest-tracker') |
| 63 | + ->label('Bucket') |
| 64 | + ->maxLength(255) |
| 65 | + ->required(fn (Closure $get) => $get('v2_enabled') == true) |
| 66 | + ->columnSpan(1), |
| 67 | + TextInput::make('v2_token') |
| 68 | + ->label('Token') |
| 69 | + ->maxLength(255) |
| 70 | + ->password() |
| 71 | + ->required(fn (Closure $get) => $get('v2_enabled') == true) |
| 72 | + ->disableAutocomplete() |
| 73 | + ->columnSpan(['md' => 2]), |
| 74 | + ]), |
63 | 75 | ]) |
64 | 76 | ->compact() |
65 | 77 | ->columns([ |
|
0 commit comments