skyracer2012
skyracer2012
FFilament
Created by skyracer2012 on 6/12/2024 in #❓┊help
Add arbitrary row to Table Model
I was wondering on how I can add a custom entry to the table rows without the need for a database row corresponding to the model. So if I for example have a Model named Cars I then want to add a new car to the table without having this car as a Model. One such practical example would be a car management application which always has the latest f1 winning car in the table based on some formula one api without affecting the database of the actual cars.
2 replies
FFilament
Created by skyracer2012 on 5/2/2024 in #❓┊help
Create a livewire component via javascript
I am working on a solution where I need multiple of the same livewire components on demand. Such as in a repeater. Does anyone know a way to create a livewire component via javascript? I tried to add it via .innerHTML of "<livewire:counter />". This however caused this directive to be replaced with the actual livewire component within javascript. To circumvent this I also obfuscated it by appending two strings ("<livew" + "ire:counter />"). This didnt get picked up by livewire however.
4 replies
FFilament
Created by skyracer2012 on 5/1/2024 in #❓┊help
Routes in web.php don't work if its the top level
I am using filamentphp with multi tenancy. I am currently trying to install clockwork but it I cannot access the /clockwork uri. Anyways. I tracked down the problem to all urls which are for example localhost/test or localhost/example. Everything such as /localhost/test/test or localhost/foo/bar works. Is this a known thing? Any way to bypass it? My localhost/test route does show up on php artisan route:list:
GET|HEAD / .................................................................................................................................................. filament.app.tenant › Filament\Http › RedirectToTenantController
GET|HEAD admin ...................................................................................................................................... filament.admin.pages.admin-dashboard › App\Filament\Pages\AdminDashboard
... much /admin stuff
GET|HEAD admin/users/{record}/edit .................................................................................................. filament.admin.resources.users.edit › App\Filament\Resources\UserResource\Pages\EditUser
... other stuff ....
ANY laravel/login ....................................................................................................................................................... login › Illuminate\Routing › RedirectController
... livewire/ stuff...
GET|HEAD test ................................................................................................................................................................................................................
GET|HEAD {tenant} .................................................................................................................................................. filament.app.pages.dashboard › Filament\Pages › Dashboard
... {tenant}/xxx stuff
GET|HEAD / .................................................................................................................................................. filament.app.tenant › Filament\Http › RedirectToTenantController
GET|HEAD admin ...................................................................................................................................... filament.admin.pages.admin-dashboard › App\Filament\Pages\AdminDashboard
... much /admin stuff
GET|HEAD admin/users/{record}/edit .................................................................................................. filament.admin.resources.users.edit › App\Filament\Resources\UserResource\Pages\EditUser
... other stuff ....
ANY laravel/login ....................................................................................................................................................... login › Illuminate\Routing › RedirectController
... livewire/ stuff...
GET|HEAD test ................................................................................................................................................................................................................
GET|HEAD {tenant} .................................................................................................................................................. filament.app.pages.dashboard › Filament\Pages › Dashboard
... {tenant}/xxx stuff
13 replies
FFilament
Created by skyracer2012 on 12/21/2023 in #❓┊help
Change Models loaded in Table
Is there any hook that can be run after a query executes so that there is the possibility to for example load additional data without having a n+1 problem in the table builder? I don't want to Join the data via modifyQueryUsing. Is there any different approach?
5 replies
FFilament
Created by skyracer2012 on 11/15/2023 in #❓┊help
ActiveTab not updating
I am currently using the Tab component in an Edit Page. I am trying to conditionally load a ViewField only once the tab is open because it requires calling an api to get the desired content. The View is not called when it is hidden which is exactly what I want. However when I access the getActiveTab() function of the tab it does not show the current active tab even though the Tab, Tabs and ViewField component all are live(). This is my testcase which I illustrated using the label of a TextInput:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Tabs::make('Label')
->live()
->tabs([
Forms\Components\Tabs\Tab::make('Test1')
->schema([
//Just to have a default tab
]),
Forms\Components\Tabs\Tab::make('Real Tab I want to lazyload')
->live()
->hidden(fn(Contact $contact) => $form->getOperation() !== 'edit')
->schema([
Forms\Components\TextInput::make("test")
->live()
->label(
fn(\Filament\Forms\Components\Component $component) =>
time() .' - ' . $component
->getContainer()->getParentComponent()
->getContainer()->getParentComponent()
->getActiveTab()
),
]),
]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Tabs::make('Label')
->live()
->tabs([
Forms\Components\Tabs\Tab::make('Test1')
->schema([
//Just to have a default tab
]),
Forms\Components\Tabs\Tab::make('Real Tab I want to lazyload')
->live()
->hidden(fn(Contact $contact) => $form->getOperation() !== 'edit')
->schema([
Forms\Components\TextInput::make("test")
->live()
->label(
fn(\Filament\Forms\Components\Component $component) =>
time() .' - ' . $component
->getContainer()->getParentComponent()
->getContainer()->getParentComponent()
->getActiveTab()
),
]),
]);
}
2 replies
FFilament
Created by skyracer2012 on 10/9/2023 in #❓┊help
Form in Global Search Action
Hey, Actions normally have a ->form function in which you can give the user a modal and so on. As I can see the GlobalSearch Action does not have this feature. Does anyone know how I can trigger a modal on pressing the action of a GlobalSearch? I saw in the docs that I can trigger livewire actions but could not find if there is a livewire action for modals. (I would need to process the result of the modal via php)
5 replies
FFilament
Created by skyracer2012 on 9/10/2023 in #❓┊help
Multiple Infolists in Form not rendering when ->live function is being used by any component
I want to display some information inside of the edit function of a Model I have. For this I have a method that loops through related Models which adds a Section to the Form for each Model. Each Section consists of this:
Forms\Components\Section::make()
->description(Str::limit($model->subject))
->collapsible()
->collapsed($collection->last() !== $model)
->compact()
->schema([
Forms\Components\View::make('filament.forms.components.model.history.body')
//->view('filament.forms.components.model.history.body')
->viewData([
'model' => $model,
]),
]);
Forms\Components\Section::make()
->description(Str::limit($model->subject))
->collapsible()
->collapsed($collection->last() !== $model)
->compact()
->schema([
Forms\Components\View::make('filament.forms.components.model.history.body')
//->view('filament.forms.components.model.history.body')
->viewData([
'model' => $model,
]),
]);
I use the View component so I can render the infolist using a custom Livewire component as described in the docs (https://filamentphp.com/docs/3.x/infolists/adding-an-infolist-to-a-livewire-component) The issue persists even with the simplest of the simple Infolists such as:
public function contentInfolist(Infolist $infolist): Infolist
{
return $infolist
->state(['test' => 'Cooltexthere'])
->schema([
TextEntry::make('test')
]);
}
public function contentInfolist(Infolist $infolist): Infolist
{
return $infolist
->state(['test' => 'Cooltexthere'])
->schema([
TextEntry::make('test')
]);
}
This now results in there being a list of Sections in the Form which all have the livewire infolist content rendered. So far everything is working as intended. When I however add another Form Component which has the ->live() attribute (and I type in the form field) every but the last rendered info list (from the multiple inside of the multiple sections) will be cleared and have no content at all. Adding some static HTML to the blade view "filament.forms.components.model.history.body" or even the one of the livewire component this gets displayed. The infolist however won't be displayed. I assume the issue has to do with livewire refreshing something due top the ->live() function. Does anyone know of such restrictions?
6 replies
FFilament
Created by skyracer2012 on 9/5/2023 in #❓┊help
Run Javascript on select change
I have a richeditor and select field in a form. The select field is a relationship which Model also contains a richeditor field. I now want the richeditor field from the form to be auto-filled with the currently selected relation's richeditor content. Is there a way to trigger javascript and pass the relationship's model data on select change? My current Idea is to add a livewire component to the schema function of the form which only contains javascript and then adding a changed listener to the select input. I however don't know how to fetch the relationship data using this approach. Does anyone have a idea to do this/inject javascript into a form page as well as getting the Model data of the selected relationship?
4 replies