Koda
Koda
FFilament
Created by Koda on 6/20/2024 in #❓┊help
Clear Button in custom form
@Leandro Ferreira Thank you. This works great
11 replies
FFilament
Created by Koda on 6/20/2024 in #❓┊help
Clear Button in custom form
No console error. Strange. Maybe a missing implement? Here a shoretd version
<?php

namespace App\Filament\Pages\XXX;

use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Forms\Set;
use Filament\Notifications\Notification;
use Filament\Pages\Page;

class CreateXXX extends Page implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

protected static string $view = 'filament.pages.xxx';

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->autofocus(),
])
->statePath('data');
}

protected function getFormActions(): array
{
return [
Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create'),

Action::make('clear')
->action(function (Set $set) {
dd(1);
$set('data.name', '',);
$set('name', '');
$this->form->fill();
})
];
}

public function create(): void
{
$this->form->fill();
Notification::make()
->success()
->title('OK')
->send();
}
}
<?php

namespace App\Filament\Pages\XXX;

use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Forms\Set;
use Filament\Notifications\Notification;
use Filament\Pages\Page;

class CreateXXX extends Page implements HasForms
{
use InteractsWithForms;

public ?array $data = [];

protected static string $view = 'filament.pages.xxx';

public function mount(): void
{
$this->form->fill();
}

public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->autofocus(),
])
->statePath('data');
}

protected function getFormActions(): array
{
return [
Action::make('create')
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
->submit('create'),

Action::make('clear')
->action(function (Set $set) {
dd(1);
$set('data.name', '',);
$set('name', '');
$this->form->fill();
})
];
}

public function create(): void
{
$this->form->fill();
Notification::make()
->success()
->title('OK')
->send();
}
}
<x-filament-panels::page
@class([
'fi-resource-create-record-page',
])
>
<x-filament-panels::form
id="form"
wire:submit="create"
>
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getFormActions()"
/>
</x-filament-panels::form>
</x-filament-panels::page>
<x-filament-panels::page
@class([
'fi-resource-create-record-page',
])
>
<x-filament-panels::form
id="form"
wire:submit="create"
>
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getFormActions()"
/>
</x-filament-panels::form>
</x-filament-panels::page>
11 replies
FFilament
Created by Koda on 6/20/2024 in #❓┊help
Clear Button in custom form
@Tally A dd is not showing, and the Action is Filament\Actions\Action
11 replies
FFilament
Created by Koda on 6/17/2024 in #❓┊help
Disable/Hide Checkbox item in CheckboxList
@toeknee Thank you. have you an example?
10 replies
FFilament
Created by Koda on 6/17/2024 in #❓┊help
Disable/Hide Checkbox item in CheckboxList
Thank you. This work. Have you also a solution to uncheck the value for a better user experience?
10 replies
FFilament
Created by Koda on 6/17/2024 in #❓┊help
Disable/Hide Checkbox item in CheckboxList
Thank you. I forgot live(). But what is the solution to uncheck and disable or hide? I thought I found a solution with false but this is wrong
CheckboxList::make('options')
->options([
'a' => 'A',
'b' => 'B',
'c' => 'C',
'd' => 'D',
])
->live()
->disableOptionWhen(function($value, Set $set, $state) {
if(in_array('a', $state)) {
//if($value === 'a') { # value is allways a...?
$set('options.b', false);
}
}),
CheckboxList::make('options')
->options([
'a' => 'A',
'b' => 'B',
'c' => 'C',
'd' => 'D',
])
->live()
->disableOptionWhen(function($value, Set $set, $state) {
if(in_array('a', $state)) {
//if($value === 'a') { # value is allways a...?
$set('options.b', false);
}
}),
10 replies
FFilament
Created by Koda on 6/17/2024 in #❓┊help
Disable/Hide Checkbox item in CheckboxList
@Leandro Ferreira Thank you. Is disableOptionWhen not only to disable an option on page load? I need multiple Rule To disable D if I check A, Disable D and E if I check B,...
10 replies
FFilament
Created by Koda on 6/13/2024 in #❓┊help
TextInput with an autocomplete function
I think it is a problem with Safari. In Chrome it works, in Safari I don't geht a List
9 replies
FFilament
Created by Koda on 6/13/2024 in #❓┊help
TextInput with an autocomplete function
Thank you. I have forgot that I have try a few days before. But I don't geht a option to select the values
->live(debounce:400)
->autocomplete('off')
->datalist(function(Set $set, $state) {
$data = [];
if($state != null) {
$data = (new MyService())->autocomplete($state);
}
return $data;
})
->live(debounce:400)
->autocomplete('off')
->datalist(function(Set $set, $state) {
$data = [];
if($state != null) {
$data = (new MyService())->autocomplete($state);
}
return $data;
})
$data return an array (Checked with dd($data)
9 replies
FFilament
Created by Koda on 6/13/2024 in #❓┊help
TextInput with an autocomplete function
@dissto with datalist I can't get dynamic data from an api. The value comes from api and is refresh with every input
9 replies