TiBiBa
TiBiBa
FFilament
Created by TiBiBa on 7/25/2024 in #❓┊help
Prevent allowDuplicates() when using detach action
Hi! We've implement a MorphToMany relationship that allows for a user -> user_roles -> role relationship. The pivot table looks as follows: - user_id - role_id - team_id A user is allowed to have the same role multiple times as long as the team is different. By using allowDuplicates() attaching new records works as expected. However, when attempting to detach records it crashes, as an id column is expected when allowing duplicates. Is there anyway to get this to work? Thanks in advance!
5 replies
FFilament
Created by TiBiBa on 3/26/2024 in #❓┊help
Possible to preload Select form input getSearchResultsUsing()?
Hi! I'm struggling with impelementing a custom search form input. Using the getSearchResultsUsing() function I've create a custom query based on the $search attribute. But, I would like to pre-load this query, even when the $search is still empty. Is it possible to preload this query? Thanks in advance!
1 replies
FFilament
Created by TiBiBa on 2/2/2024 in #❓┊help
Keep svg viewBox attribute on custom sanitizer doesn't work
Hi! To display icons from a svg column on the resource list page I'm attempting to overwrite the HTML sanitizer to allow rendering SVG. The SVG is whitelisted as expected, but the allowed attributes do not seem to work. I just the following code-snippet for example:
$sanitizer = new HtmlSanitizer(((new HtmlSanitizerConfig())
->allowSafeElements()
->allowElement('svg', ['fill', 'fill-opacity', 'view-box', 'viewBox', 'preserveAspectRatio', 'stroke', 'stroke-width', 'xmlns'])
->allowElement('path', ['stroke-linecap', 'fill', 'fill-opacity', 'stroke-linejoin', 'd'])
->allowElement('g', ['fill', 'fill-opacity'])
->allowElement('polyline', ['fill', 'points'])
->allowElement('polygon', ['fill', 'points'])
->allowRelativeLinks()
->allowRelativeMedias()
->allowAttribute('class', allowedElements: '*')
->allowAttribute('style', allowedElements: '*')
->withMaxInputLength(500000)));

$svg = $sanitizer->sanitize($record->svg);

dd([
'svg' => $record->svg,
'sanitized' => $svg
]);
$sanitizer = new HtmlSanitizer(((new HtmlSanitizerConfig())
->allowSafeElements()
->allowElement('svg', ['fill', 'fill-opacity', 'view-box', 'viewBox', 'preserveAspectRatio', 'stroke', 'stroke-width', 'xmlns'])
->allowElement('path', ['stroke-linecap', 'fill', 'fill-opacity', 'stroke-linejoin', 'd'])
->allowElement('g', ['fill', 'fill-opacity'])
->allowElement('polyline', ['fill', 'points'])
->allowElement('polygon', ['fill', 'points'])
->allowRelativeLinks()
->allowRelativeMedias()
->allowAttribute('class', allowedElements: '*')
->allowAttribute('style', allowedElements: '*')
->withMaxInputLength(500000)));

$svg = $sanitizer->sanitize($record->svg);

dd([
'svg' => $record->svg,
'sanitized' => $svg
]);
Resulting in the following dd() output:
"svg" => "<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><g ..."
"sanitized" => "<svg><g ..."
"svg" => "<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><g ..."
"sanitized" => "<svg><g ..."
But I did specify on the sanitizer to allow the viewBox attribute as well. This results in unpredictable sizes. Does anyone have a clue on how to fix this? Thanks in advance!
4 replies
FFilament
Created by TiBiBa on 1/16/2024 in #❓┊help
Possible to get record from the table row above current row?
For a custom table action I'm attempting to implement an action to copy the values from the selectColumn in the table row above the current one into the selectColumn of the current row. But I can't figure out how to get the current row index and/or the row above. Is this possible? Thanks in advance!
4 replies
FFilament
Created by TiBiBa on 12/13/2023 in #❓┊help
Crash on list page when switching results per page to 'all'
When on a list page and switching the results per page option to 'all' the pages crashes with a 500 server error. Worst is that I'm unable to visit this page as the filter is saved in the session and keeps returning an error. The following error is thrown:
Noticed exception 'Illuminate\View\ViewException' with message 'Unsupported operand types: string * int
Noticed exception 'Illuminate\View\ViewException' with message 'Unsupported operand types: string * int
Anyone have a clue how to solve this? Thanks in advance!
2 replies
FFilament
Created by TiBiBa on 11/1/2023 in #❓┊help
Possible to open url in new tab with table form action?
Hi! I'm looking for a way to implement a unique table action. On the Action I want to open a model in which the user can enter some data. On submit I want to open a new tab with a url based on this data. With a normal action this is possible with ->openUrlInNewTab(). However, I'm unable to find a work-around for a action for which we overwrite the action using a custom modal. The only way I found is using redirect() but this is not the desired flow. Thanks in advance!
2 replies
FFilament
Created by TiBiBa on 10/2/2023 in #❓┊help
Possibility to hide sign out option in user menu?
Hi! Our admin panel created with Filament is guarded by an IAP and we don't need the logout functionality. I'm looking for a way to disable the logout option in the user menu bar. Does anyone have a suggestion how to implement this? Thanks in advance!
7 replies
FFilament
Created by TiBiBa on 9/25/2023 in #❓┊help
File upload form component not working due to fallback on default guard.
Hi! I'm struggling with implementing the File upload form component. The storage driver is configured to Google Cloud Storage using the Spatie library. This all works fine except for a guard issue. When uploading a file in the form the upload process crashes on a non-existing Authentication provider. Debugging this code results in the finding that the upload process automatically falls back on the default guard (web) whereas we using a custom guard for our Admin panel. Folllowing the stack-trace it seems to be that the guard name is empty when the following function is called: src/Illuminate/AuthAuthServiceProvider.php#guard(). This function automatically takes the default driver when no guard name is provided. Changing the guard name in the config from web to our custom Admin guard indeed works and the upload process is fine. However, this is undesirable. Does someone have a clue why the guard name can be empty? Thanks in advance! The custom guard is already set correctly on the PanelProvider using the authGuard() function.
2 replies
FFilament
Created by TiBiBa on 9/8/2023 in #❓┊help
Unable to dynamically update own state of RichEditor for component?
Hi! For a form I would like to process the input data of a RichEditor using the afterStateUpdated() hook. The data is processed and a HTML table structured string is return, that is supposed to be set as the value of the editor itself. The purpose is to enable pasting data from excel and we render this nicely as preview. The following snippet used to work fine in v2:
RichEditor::make('users')->live()
->disableAllToolbarButtons()
->afterStateUpdated(function (Set $set, Get $get) {
$userData = self::parseExcelData($get('users'));
$set('users', self::parseTableData($userData));
}),
RichEditor::make('users')->live()
->disableAllToolbarButtons()
->afterStateUpdated(function (Set $set, Get $get) {
$userData = self::parseExcelData($get('users'));
$set('users', self::parseTableData($userData));
}),
However, the form field is not updated when providing some input. I already verified that the last function, parseTableData(), returns data as expected. Weirdly enough, an identical implementation but with a TextInput works just fine! Anyone a clue how this can be fixed? Thanks in advance!
2 replies
FFilament
Created by TiBiBa on 8/30/2023 in #❓┊help
Notifications works when triggered on mount() but not when triggered on submit()?
Hi! I'm stuck on showing notifications in the panel builder. I'm trying to show a notification to the user to inform them that no results are found for their search query. Using the following approach on a custom page:
public function submit(): void
{
Notification::make()
->title('This should be shown on submit')
->warning()
->send();

// dd('We get here!');
}
public function submit(): void
{
Notification::make()
->title('This should be shown on submit')
->warning()
->send();

// dd('We get here!');
}
The notification is never shown but when I uncomment the dd() this is executed as expected. The weird thing is that the notifications seem to work fine on the mount() function. The following snippets shows a notification when re-loading the page:
public function mount(): void
{
Notification::make()
->title('This is a test notifications')
->warning()
->send();
$this->form->fill([]);
}
public function mount(): void
{
Notification::make()
->title('This is a test notifications')
->warning()
->send();
$this->form->fill([]);
}
Thanks in advance!
18 replies
FFilament
Created by TiBiBa on 8/28/2023 in #❓┊help
Associate headerAction not showing on Relation manager?
Hi! We've just migrated to v3 and have some issues with a HasMany relation and the AssociateAction. When adding an AssociateAction to the headerActions of the Relation Manager table the action button is not shown. Using the following snippet the normal action is displayed as expected but the associate action is not. I didn't run into this issue with v2 and unable to find a cause, thanks in advance!
->headerActions([ Tables\Actions\Action::make('test123'),
Tables\Actions\AssociateAction::make(),
])
->headerActions([ Tables\Actions\Action::make('test123'),
Tables\Actions\AssociateAction::make(),
])
Edit I run into the same issue with an Edit and Delete action on the items. The View action is rendered as expected. However, Detach actions in turn don't work either. I've tried this accross multiple relation managers.
4 replies
FFilament
Created by TiBiBa on 8/25/2023 in #❓┊help
Attach / Detach with timestamps and soft deletes?
Hi! For a BelongstoMany relationship with a pivot table we use the RelationManager and the Attach() and Detach() action to add and delete a relation. However, on the pivot table we also have timestamp columns (created_at, updated_at and deleted_at). Is there a way to use soft_deletes and make these follow the Laravel timestamps convention? Thanks in advance!
3 replies
FFilament
Created by TiBiBa on 8/14/2023 in #❓┊help
Possible to dispatch event in submit() function after variables are updated?
Hi! When updating from v2 to v3 we ran into an error that we are unable to solve. Within a custom page with a form we perform some data mutations in the submit() function and store these in a variable $this->tree. Which, when exists, is automatically updated in the rendered page. Lastly in the function we threw an emit() to trigger a JS function in the front-end and load an external library. This al worked fine but with the switch to v3 (and Livewire v3) emit() is replaced by dispatch(). For some reason the ordering of events is now changed. The dispatch() is thrown before the variable is updated on the front-end, making the JS library crash as no value is found. The same use-case worked fine in v2. Is there a way to force a re-render within the submit() function before I manually dispatch an event? Alternatively would be to dispatch the custom event after the updating in some way. Thanks in advance!
5 replies
FFilament
Created by TiBiBa on 8/3/2023 in #❓┊help
Alternative for emit() in v3?
Hi! When updating from v2 to v3 a custom page broke due to an emit does not exist. error. The page implements HasForms and worked fine in v2. The event was caught in the blade template like this:
Livewire.on('dataUpdated', () => {
console.log('hello!');
initializeTree();
})
Livewire.on('dataUpdated', () => {
console.log('hello!');
initializeTree();
})
Do anyone have a suggestion how to handle the same functionaliy in v3? Thanks in advance!
6 replies
FFilament
Created by TiBiBa on 8/3/2023 in #❓┊help
Option to set MarkdownEditor background color
5 replies
FFilament
Created by TiBiBa on 7/28/2023 in #❓┊help
Unable to display notifications in admin panel
61 replies
FFilament
Created by TiBiBa on 6/28/2023 in #❓┊help
Dynamically disabling form field doesn't work?
Hi I'm look to dynamically disable a form field based on if the field is filled. Using the following snippet I expect the form field to be disabled after, but it doesn't do anything:
->disabled(function (Closure $get) {
if ($get('users')) {
return true;
} return false;
})
->disabled(function (Closure $get) {
if ($get('users')) {
return true;
} return false;
})
Am I doing something wrong? Edit The snippet does work on a "normal" TextInput but not on a MarkdownEditor. However, the same disabled() property should work.
4 replies
FFilament
Created by TiBiBa on 6/28/2023 in #❓┊help
Dynamically switch MarkdownEditor to preview mode?
Hi! I'm currently working on a custom page were the users can paste some data (for example for excel), which we validate and parse directly with the wire:paste action. Afterwards I would like to dynamically change the mode for the editor from Edit to Preview. Is this possible? Thanks in advance!
4 replies
FFilament
Created by TiBiBa on 6/23/2023 in #❓┊help
Crash on getTableFilterState() on select filter with relationship
Hi! We are looking to prevent initial loading of the first x resources when opening a list resource page and came up with a solution like this:
protected function getTableQuery(): Builder
{
$this->countActiveFilters();
return parent::getTableQuery()
->when(
$this->filterCount == 0,
fn ($query) => $query->where(DB::raw('1 = 0')),
);

return parent::getTableQuery();
}
protected function getTableQuery(): Builder
{
$this->countActiveFilters();
return parent::getTableQuery()
->when(
$this->filterCount == 0,
fn ($query) => $query->where(DB::raw('1 = 0')),
);

return parent::getTableQuery();
}
Whereas the countActiveFilters() is as follows. This works fine when using a text input filter or a select filter with manual options. But when using a select filter based on a relationship the page crashes. Is there any way to improve this code? Thanks in advance!
private function countActiveFilters(): void
{
$this->filterCount = 0;
if (!isset($this->cachedTableFilters)) {
return;
}
foreach ($this->getTableFilters() as $filter) {
$filterContainer = $this->getTableFilterState($filter->getName()) ?? [];
$data = array_values($filterContainer);
$this->filterCount += count(array_filter($data));
}
}
private function countActiveFilters(): void
{
$this->filterCount = 0;
if (!isset($this->cachedTableFilters)) {
return;
}
foreach ($this->getTableFilters() as $filter) {
$filterContainer = $this->getTableFilterState($filter->getName()) ?? [];
$data = array_values($filterContainer);
$this->filterCount += count(array_filter($data));
}
}
14 replies
FFilament
Created by TiBiBa on 6/21/2023 in #❓┊help
Add condition to recordSelectOptionsQuery() based on current resource
Hi! When in the relation manager I'm trying to attach a new relation. I would like to modify the query options to only allow a specific subset of options. I would like to adjust the recordSelectOptionsQuery() condition based on an attribute of the resource for which I'm adding a relation. Is this possible? Thanks in advance!
1 replies