© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
rg.block

Placeholder content based on conditional logic based on value from another component?

Is it possible to set the content of a Placeholder with conditional logic if the value of another component or even the value of a property I am using on a ->mountUsing is equal to something?

In more detail, I have a table and I am using Action to open a modal window. The modal has a few TextInputs whose values are being set with ->mountUsing, and then I have a Repeater using ->relationship(), and the repeater has a Placeholder and other components inside. I would like the content of the Placeholder to be something if the value of one of the mounted TextInputs is 1, something else if it is 2, and so on.

The code for my Action is:

Action::make('viewPackage')
                ->label('View')
                ->mountUsing(fn (Forms\ComponentContainer $form, Package $record)  => $form->fill([
                    'package_name' => $record->name,
                    'number_of_documents' => $record->number_of_documents,
                    'state_name' => $record->jurisdiction->state->name,
                    'jurisdiction_name' => $record->jurisdiction->name,
                    'provider' => $record->provider_id,
                ]))
                ->icon('heroicon-s-eye')
                ->color('success')
                ->visible(fn ($record) => $record->status_id === 3)
                ->action(function (Package $record, array $data): void {
                    $record->package()->associate($data['packageId']);
                    $record->save();
                })
Action::make('viewPackage')
                ->label('View')
                ->mountUsing(fn (Forms\ComponentContainer $form, Package $record)  => $form->fill([
                    'package_name' => $record->name,
                    'number_of_documents' => $record->number_of_documents,
                    'state_name' => $record->jurisdiction->state->name,
                    'jurisdiction_name' => $record->jurisdiction->name,
                    'provider' => $record->provider_id,
                ]))
                ->icon('heroicon-s-eye')
                ->color('success')
                ->visible(fn ($record) => $record->status_id === 3)
                ->action(function (Package $record, array $data): void {
                    $record->package()->associate($data['packageId']);
                    $record->save();
                })


Where 'provider' => $record->provider_id, is the value I need to be used on the Placeholder logic.

Right now my Placeholder code is just setting the value like:

Placeholder::make('document_type_name')->content(fn ($record) => $record?->documentTypePrimary->name),
Placeholder::make('document_type_name')->content(fn ($record) => $record?->documentTypePrimary->name),
which works when the provider is 1, but I am not evaluating that, so I would like to check for whatever value the provider is and then set $record?->documentTypePrimary to be ->documentTypeSecondary, ->documentTypeTernary, etc.

Is that something that can be done here, or perhaps I am just overcomplicating things here? I have tried using a function but I just cant find a way to access the value of provider

I am adding the gist to the entire action code here for full reference.

https://gist.github.com/rgut13rrez/e18fc9aafb72e26e7c156ea2c42653db
Gist
packages.php
GitHub Gist: instantly share code, notes, and snippets.
packages.php
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Textinput value like Placeholder content?
FilamentFFilament / ❓┊help
3y ago
call component from another component
FilamentFFilament / ❓┊help
2y ago
Conditional widget based on RelationManager
FilamentFFilament / ❓┊help
3y ago
Form Component Placeholder
FilamentFFilament / ❓┊help
2y ago