Kuldeep
Kuldeep
FFilament
Created by Kuldeep on 9/5/2024 in #❓┊help
How can I create a ToggleColumn to change status from the list page
I've tried with multiple solution to add a ToggleColumn to list page but didn't get a proper success for this. Issues: Into the database side data is updating for the status column but in the list page toggle is not getting proper record and showing only active/inactive as a toggle. Here is my code, is ther any problem or I'm missing something or else?
ToggleColumn::make('status')
->onColor('success')
->offColor('warning')
->onIcon('heroicon-s-check')
->offIcon('heroicon-s-x-mark')
->label('Status')
->getStateUsing(fn($record): bool => $record->status === 1)
->afterStateUpdated(function ($record, $state, $livewire) {
$record->update(['status' => $state ? 1 : 0]);

Notification::make()
->title('')
->success()
->body('Status updated successfully!')
->send();

$livewire->getTableRecords();
}),
ToggleColumn::make('status')
->onColor('success')
->offColor('warning')
->onIcon('heroicon-s-check')
->offIcon('heroicon-s-x-mark')
->label('Status')
->getStateUsing(fn($record): bool => $record->status === 1)
->afterStateUpdated(function ($record, $state, $livewire) {
$record->update(['status' => $state ? 1 : 0]);

Notification::make()
->title('')
->success()
->body('Status updated successfully!')
->send();

$livewire->getTableRecords();
}),
21 replies
FFilament
Created by Kuldeep on 12/14/2023 in #❓┊help
403 forbidden error
I'm trying to add a modal action to the custom page. When clicking on the button it'll go to 403 forbidden error every time. Any solution for the same?
12 replies
FFilament
Created by Kuldeep on 10/18/2023 in #❓┊help
List page loading issue
The List page is getting the same pagination if I go to another page and again came back to the same page. Any idea why this is happening? I'm using filament V2?
2 replies
FFilament
Created by Kuldeep on 10/11/2023 in #❓┊help
Is there a way to get the value of the filters through custom and use them in the custom query?
I've used this trick: https://v2.filamentphp.com/tricks/use-custom-view-for-table-content to display custom view and into the method getTableContent() I'm running my query to get the result. Just because I'm having multiple queries. Now from the tables filters I wanted to use those filters in my custom queries to get the result properly and display into the table. So, how can I get the value of the filters in the method getTableContent() to use them in my custom queries?
7 replies
FFilament
Created by Kuldeep on 8/2/2023 in #❓┊help
Update record with multiple tables in the single form
the a
Hello, I'm having an EditRecord resource which is having a 3+ wizard step form. In each wizard I'm having different table records with relationships. In Section::make() it'll be easier to make a form with relationship and update record but, I need to save that particular record to another table. So, how it can get easily updated into the database?
1 replies
FFilament
Created by Kuldeep on 7/13/2023 in #❓┊help
Error: mountTableAction
Hello, I'm getting an error in my livewire component. I've created a listing through this: https://filamentphp.com/docs/2.x/tables/getting-started#preparing-your-livewire-component Now, I wanted to add an edit, delete button to make a process. My code is attached here. The component is used in a filament resource for a tab section for the module.
8 replies
FFilament
Created by Kuldeep on 6/14/2023 in #❓┊help
File upload not working with 2+ files
I'm getting an issue with the spatie media library plugin. Only 2 photos are uploaded at a time though we've selected 2+. My code is:
protected function getFormSchema(): array
{
return [
CustomFileUpload::make('photos')
->label('')
->multiple()
->collection('photos')
->removeUploadedFileButtonPosition('right')
->panelLayout('grid')
->panelAspectRatio('3:2')
->placeholder('<svg enable-background="new 0 0 50 50" height="50px" id="Layer_1" version="1.1" viewBox="0 0 50 50" width="50px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect fill="none" height="50" width="50"/><line fill="none" stroke="#000000" stroke-miterlimit="10" stroke-width="4" x1="9" x2="41" y1="25" y2="25"/><line fill="none" stroke="#000000" stroke-miterlimit="10" stroke-width="4" x1="25" x2="25" y1="9" y2="41"/></svg> Add Another')
->responsiveImages()
->imageCropAspectRatio('3:2')
->enableReordering()
->disk('s3Public')
->afterStateUpdated(function (?Model $record, Forms\Components\Field $component, $state) {
$this->photoAutoSave(); })
];
}

public function photoAutoSave(): void
{
$validator = Validator::make(['data' => $this->form->getState()], $this->getRules());
if (!count($validator->invalid())) {
$this->save();
}
}

// CustomFileUpload component:
<?php

namespace App\Forms\Components;

use Filament\Forms\Components\SpatieMediaLibraryFileUpload;

class CustomFileUpload extends SpatieMediaLibraryFileUpload
{
protected string $view = 'forms.components.custom-file-upload';
}
protected function getFormSchema(): array
{
return [
CustomFileUpload::make('photos')
->label('')
->multiple()
->collection('photos')
->removeUploadedFileButtonPosition('right')
->panelLayout('grid')
->panelAspectRatio('3:2')
->placeholder('<svg enable-background="new 0 0 50 50" height="50px" id="Layer_1" version="1.1" viewBox="0 0 50 50" width="50px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><rect fill="none" height="50" width="50"/><line fill="none" stroke="#000000" stroke-miterlimit="10" stroke-width="4" x1="9" x2="41" y1="25" y2="25"/><line fill="none" stroke="#000000" stroke-miterlimit="10" stroke-width="4" x1="25" x2="25" y1="9" y2="41"/></svg> Add Another')
->responsiveImages()
->imageCropAspectRatio('3:2')
->enableReordering()
->disk('s3Public')
->afterStateUpdated(function (?Model $record, Forms\Components\Field $component, $state) {
$this->photoAutoSave(); })
];
}

public function photoAutoSave(): void
{
$validator = Validator::make(['data' => $this->form->getState()], $this->getRules());
if (!count($validator->invalid())) {
$this->save();
}
}

// CustomFileUpload component:
<?php

namespace App\Forms\Components;

use Filament\Forms\Components\SpatieMediaLibraryFileUpload;

class CustomFileUpload extends SpatieMediaLibraryFileUpload
{
protected string $view = 'forms.components.custom-file-upload';
}
Note: This is in the EditRecord resource.
7 replies
FFilament
Created by Kuldeep on 6/2/2023 in #❓┊help
How can we pass a record object to the modal content
Hello, I'm having a list record through the livewire component and I've used Tables\Actions\ViewAction and wanted to display custom modal content through this. But I don't know some how $record is not passing through the modal content blade file.
protected function getTableActions(): array
{
return [
Tables\Actions\ViewAction::make('view')
->label('')
->icon('heroicon-s-eye')
->modalContent(view('livewire.modal-content', ['record_id' => fn($record) => $record->id])),
];
}
protected function getTableActions(): array
{
return [
Tables\Actions\ViewAction::make('view')
->label('')
->icon('heroicon-s-eye')
->modalContent(view('livewire.modal-content', ['record_id' => fn($record) => $record->id])),
];
}
2 replies
FFilament
Created by Kuldeep on 5/26/2023 in #❓┊help
Make a toggle required based on the other 3 fields
Hey I wanted to change the toggle required/not required based on the change of select value. From the select value, I'm having 3 values on which the selection toggle is required and the rest of the values toggle is not required. This will be the initial case. I've to update the toggle based on 3 other fields. My code is attached. How can I do it?
15 replies
FFilament
Created by Kuldeep on 5/25/2023 in #❓┊help
Add action to the livewire component
I'm using this livewire component: https://filamentphp.com/docs/2.x/tables/getting-started#preparing-your-livewire-component to display the list and wanted to add an Action before the list. I've tried with adding a custom code to the blade before
$this->table
$this->table
but not worked. This will be the same process as the Filament resource but it'll not possible in my case because I'm using a Filament view resource and into that, I've used the livewire component in the Tab section.
20 replies
FFilament
Created by Kuldeep on 3/30/2023 in #❓┊help
Open modal from input field label
I wanted to open a modal from the checkbox label text, like Terms & Conditions.
Forms\Components\Checkbox::make('terms')
->label('I agree with ')
->hint("[terms & condition.](" . url("/terms") . ")")
Forms\Components\Checkbox::make('terms')
->label('I agree with ')
->hint("[terms & condition.](" . url("/terms") . ")")
The above code works but the link will come in the hint section. Also, it'll open another page and I want to show terms & conditions in the modal.
25 replies
FFilament
Created by Kuldeep on 3/30/2023 in #❓┊help
Profile picture display
Through this trick: https://filamentphp.com/tricks/uploading-profile-image Can we display a default profile picture in form?
2 replies
FFilament
Created by Kuldeep on 3/10/2023 in #❓┊help
Custom AlpineJS validation
3 replies
FFilament
Created by Kuldeep on 3/7/2023 in #❓┊help
Same width text fields in the form
17 replies
FFilament
Created by Kuldeep on 3/3/2023 in #❓┊help
Custom Validation
I'm having a 2 fields: (1) Price (2) Checkbox Task 1) If the price is less than a specific amount then the checkbox check is required. Task 2) Display a validation error message only if the price is less than a specific amount. Form submit will be allowed I've done below code and it's not working properly: Forms\Components\TextInput::make('price') ->label('Price'), Forms\Components\Toggle::make('checkbox') ->label('Checkbox') ->rules(['required_if:price,(X Amount)']), I've tried with custom rule but it's not working properly. How can I do this?
33 replies