maltebaer
maltebaer
FFilament
Created by maltebaer on 2/1/2024 in #❓┊help
passing data to infolist action
hey friends 👋🏽, i want to use filament to display repeatable data, like in some kind of accordion. i use the infolist builder, passing my data via state(). now my data includes details that i want to show inside a modal. i want to trigger the modal from within the section body, not the header. my idea is as follows:
public function fooInfolist(Infolist $infolist): Infolist
{
return $infolist
->state($this->foo)
->schema([
RepeatableEntry::make('foo')
->schema([
Section::make('name')
->collapsible()
->schema([
TextEntry::make('name'),
ViewEntry::make('bar')
->view('bar')
->registerActions([
Action::make('showDetails')
->modalContent(view('bar-details'))
->infolist([
Tabs::make('Tabs')
->tabs([
Tab::make('Tab 1')
->schema([
TextEntry::make('bar.name')
]),
])
])
]),
])
])
]);
}
public function fooInfolist(Infolist $infolist): Infolist
{
return $infolist
->state($this->foo)
->schema([
RepeatableEntry::make('foo')
->schema([
Section::make('name')
->collapsible()
->schema([
TextEntry::make('name'),
ViewEntry::make('bar')
->view('bar')
->registerActions([
Action::make('showDetails')
->modalContent(view('bar-details'))
->infolist([
Tabs::make('Tabs')
->tabs([
Tab::make('Tab 1')
->schema([
TextEntry::make('bar.name')
]),
])
])
]),
])
])
]);
}
the setup works fine. i have multiple cards and i can open the modal. my problem is, that i'm not able to pass the data (here bar) inside the modal. i have two ideas, either create a custom view bar-details.blade or, even better, use another infolist builder inside the modal. do you folks have any idea? or maybe even a completely different approach?
4 replies
FFilament
Created by maltebaer on 1/5/2024 in #❓┊help
register chartjs plugin
is there an official way to register a chartjs plugin? in the docs i could not find anything related to that. here, on discord, i found this post about how to do it. it does work fine but i'm not totally happy with publishing filament scripts and views.
3 replies
FFilament
Created by maltebaer on 12/20/2023 in #❓┊help
infolist: access state of another field and/or access index of repeatable entry
hey folks, i want implement an infolist component which i'm passing data via the state method. no record available. now i want to add an suffix to a field based on the state of another field. i know that within the form builder this is possible using $get. does this exists for infolist too? could not find anything related... my other idea was to build my own livewire component to implement the field + suffix myself. since this is used inside a repeatable entry i would need know the index of the current item/iteration. is this possible?
RepeatableEntry::make('projects')
->schema([
Split::make([
TextEntry::make('name'),
TextEntry::make('foo.value')
->suffix(fn (Get $get) => $get('foo.is_percentage') ? '%' : ''),
TextEntry::make('foo.is_percentage')
->hidden(),
Livewire::make(Bar::class, ['project' => $this->projects[$index]]),
])
])
RepeatableEntry::make('projects')
->schema([
Split::make([
TextEntry::make('name'),
TextEntry::make('foo.value')
->suffix(fn (Get $get) => $get('foo.is_percentage') ? '%' : ''),
TextEntry::make('foo.is_percentage')
->hidden(),
Livewire::make(Bar::class, ['project' => $this->projects[$index]]),
])
])
2 replies
FFilament
Created by maltebaer on 12/5/2023 in #❓┊help
make use of tailwind layers in custom theme
following the docs, i created a custom theme. now i want to apply some base styles to my panel. usually i would wrap them inside tailwinds base layer.
@layer base {
@apply bg-red-500;
}
@layer base {
@apply bg-red-500;
}
if i paste that snippet inside theme.css i get the following error
`@layer base` is used but no matching `@tailwind base` directive is present.
`@layer base` is used but no matching `@tailwind base` directive is present.
i'm not sure if that is a bug or if i'm applying the styles in the wrong place. the other option would be to add the classes directly in the markup. is there any way to hook into/apply styles to <html> and <body> within the panel builder?
5 replies
FFilament
Created by maltebaer on 6/19/2023 in #❓┊help
handle form component visibility with javascript
hey folks, i ran into the following problem. using the form builder i render a survey that has a lot of subquestions (a question only visible if a certain answer was given). locally everything is fine. however live it feels very slow (especially with throttled network) and if you make multiple clicks per second (e.g. checkbox list), you even loose state because of the re-render. now my idea is to initially render all the questions and do the show/hide part with javascript. what is your suggested approach on tackling this issue? is there a hidden()/visible() javascript counterpart to the already available methods? how do you track the state in the browser? is there some kind of obejct i can hook into? fyi: additional i use a wizard to display only small chunks of the survey at once. any kind of input/ideas highly appreciated!
3 replies
FFilament
Created by maltebaer on 5/17/2023 in #❓┊help
getTableQuery() for pivot table that does not have a primary key
hey friends, i try to display a pivot table that does not have a primary key. i have a model for the pivot table. if i use the following query ´´´php protected function getTableQuery(): Builder|Relation { return Insight::query(); } ´´´ i get the following error: ´´´ App\Http\Livewire*::getTableRecordKey(): Return value must be of type string, null returned ´´´ if i add a primary key to the pivot table, it works without problems. any ideas?
3 replies