KarlisJ
KarlisJ
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
This was fun, thanks @ConnorHowell for joining
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
The query need to be set as closure
$table->query(function () {
// obtain $query
// get $selectableColumns from script above
return $query->select($selectableColumns)->addSelect('id');
})
$table->query(function () {
// obtain $query
// get $selectableColumns from script above
return $query->select($selectableColumns)->addSelect('id');
})
because session is updated only once the table is initialized. So when user checks new column to toggle, it's not yet in the session. Using closure fixes that.
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
$selectableColumns = collect(session()->get($this->getTableColumnToggleFormStateSessionKey()) ?? [])
->filter(fn(bool $value, string $column) => $value )
->keys()
->toArray();
$selectableColumns = collect(session()->get($this->getTableColumnToggleFormStateSessionKey()) ?? [])
->filter(fn(bool $value, string $column) => $value )
->keys()
->toArray();
Coupled with
$query->select($selectableColumns)->addSelect('id');
$query->select($selectableColumns)->addSelect('id');
works. But only once user has interacted with togglable form. It's enough for me, since I'm in control of which columns are toggled by default and can use that as the fallback
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
I think I can get it working with $this->getTableColumnToggleFormStateSessionKey() but the value is empty on first load. Sadly, getDefaultTableColumnToggleState can't be used for fallback. Getting
Typed property App\Filament\Pages\ListRegistryEntries::$table must not be accessed before initialization
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
Tried setting columns to the table and then calling the getVisibleColumns but getting all columns.
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
the method returns empty array
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
Yeah, that doesn't work well, because I need to define the query in the same time that columns are defined
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
dd(session()->get($this->getTableColumnToggleFormStateSessionKey()));
dd(session()->get($this->getTableColumnToggleFormStateSessionKey()));
Gives me full list of all columns and true/false.
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
I found this code in the source
if (! count($this->toggledTableColumns ?? [])) {
$this->getTableColumnToggleForm()->fill(session()->get(
$this->getTableColumnToggleFormStateSessionKey(),
$this->getDefaultTableColumnToggleState()
));
}
if (! count($this->toggledTableColumns ?? [])) {
$this->getTableColumnToggleForm()->fill(session()->get(
$this->getTableColumnToggleFormStateSessionKey(),
$this->getDefaultTableColumnToggleState()
));
}
15 replies
FFilament
Created by KarlisJ on 11/15/2023 in #❓┊help
Query only toggled/displayed columns
hm, there's no method to check if it's toggled. And even so, I need to build the query around the same time that table is defined.
15 replies
FFilament
Created by codeartisan on 11/15/2023 in #❓┊help
Export to excel and pdf
https://www.google.com/search?q=filament+export+excel first 2 search results are good export plugins followed with multiple articles/guides on the topic
7 replies
FFilament
Created by KarlisJ on 10/26/2023 in #❓┊help
Interact with input state and events using Alpine
Nevermind my previous message. https://filamentphp.com/docs/3.x/forms/fields/custom#how-fields-work helped me correctly entangling the data. PoC is ready, now I just need to figure out the small things
5 replies
FFilament
Created by KarlisJ on 10/26/2023 in #❓┊help
Interact with input state and events using Alpine
Thanks for the pointer. I managed to get the communication between them. However, this
->extraInputAttributes(["x-on:focus" => "$\refs.radio_other.checked = true;"])
->extraInputAttributes(["x-on:focus" => "$\refs.radio_other.checked = true;"])
only set's it in frontend but Livewire isn't aware of it so when submitted, the previously set value will be sent to server. I'm trying to work with @entangle but having some issues. I've removed the name prop from radio input name="{{ $id }}" and used wire:model instead
wire:model="@entangle($getStatePath())"
wire:model="@entangle($getStatePath())"
This acts the same as previously, I can change the radio values and they are sent correctly to the server. But now I fail to figure out how to update the value of radio input on the focus. Given that my statepath in this example is data.radio I hardcoded that
->extraInputAttributes(["x-on:focus" => "data.radio = 'other';"]])
->extraInputAttributes(["x-on:focus" => "data.radio = 'other';"]])
but I'm getting
Uncaught ReferenceError: data is not defined
Uncaught ReferenceError: data is not defined
5 replies
FFilament
Created by KarlisJ on 10/4/2023 in #❓┊help
Free text radio option
Thanks for your response, but both examples are not what I need.
6 replies
FFilament
Created by KarlisJ on 10/3/2023 in #❓┊help
Saving form as draft and validate all except `required`
Thank you @toeknee that's good idea to play leverage closure for ->required( call. I'll explore it. Any idea on calling the method every time field value is entered?
5 replies
FFilament
Created by KarlisJ on 8/24/2023 in #❓┊help
Open action modal from dropdown item
ok, I think I have to use ActionGroup and render that instead of trying to hook actions to hardcoded blade dropdown
15 replies
FFilament
Created by KarlisJ on 8/24/2023 in #❓┊help
Open action modal from dropdown item
I'll have dropdown with multiple items. Each item will perform some task. And for some tasks, I need to gather additional input through form. As an example, I have Action
Action::make('Do something')
->form([
Select::make('input')
->options([
// Some options
])
->required(),
])
->action(function (array $data): void {
// Do something with $data['input']
})
Action::make('Do something')
->form([
Select::make('input')
->options([
// Some options
])
->required(),
])
->action(function (array $data): void {
// Do something with $data['input']
})
and I want to trigger that from dropdown item
15 replies
FFilament
Created by KarlisJ on 8/24/2023 in #❓┊help
Open action modal from dropdown item
I'm using this as example to understand how to trigger Filament action from dropdown item
15 replies
FFilament
Created by KarlisJ on 8/24/2023 in #❓┊help
Open action modal from dropdown item
So I have this
<x-filament::dropdown.list.item wire:click="openDeleteModal">
<x-filament::dropdown.list.item wire:click="openDeleteModal">
when clicked, Liviwire will trigger
public function openDeleteModal()
public function openDeleteModal()
What's the content of that method. Do I need to return Filament action from there?
15 replies
FFilament
Created by KarlisJ on 8/24/2023 in #❓┊help
Open action modal from dropdown item
still don't understand what dropdown has to do with a modal? i
In this example, there's an "Delete" item in drowdown. When clicked, I want to open confirmation modal and upon confirm perform the delete operation. To me, that action sound like "Filament action" which is not the same what "action" means in Livewire.
15 replies