bardolf_6969
bardolf_6969
FFilament
Created by bardolf_6969 on 11/20/2024 in #❓┊help
Adding a progress bar to a filament form.
I have a form that performs an import of data that can run for a long time in some circumstances. I've got the backend sorted so it doesn't timeout but occasionally I get a timeout from Cloudflare. To solves this I thought I could add a progress bar that updates as the records are being processed but I can't figure out how to make this work. I started with a custom field that is has a html progress bar in it and linked that to a progress variable in the backend. But I can't seem to get it to update as the records are being processed.
4 replies
FFilament
Created by bardolf_6969 on 11/17/2024 in #❓┊help
Custom property with Medialibrary
I'm trying to work out how to store a custom property with uploaded images to say whether it is landscape, portrait, or square. I was planning on dividing the width by the height and if the result < 0.75 = landscape, result > 1.25 = portrait, otherwise square. But how can I make those calculation on the uploaded image before it is stored in the database?
3 replies
FFilament
Created by bardolf_6969 on 10/17/2024 in #❓┊help
storage/media-library/temp
It appears my temporary upload files are not being cleared. Is there a command I should be running to do this?
2 replies
FFilament
Created by bardolf_6969 on 9/23/2024 in #❓┊help
How to change resource form opened by edit action on a relationmanager
This is going to get confusing but let me try. I have 2 models Degree and Programs, these share a many to many relationship that includes pivot table data. These tables are also accessed from a different (legacy) application so the pivot table needed to have it's own id field. So I made a model and resource in filament called DegreeProgram. I have setup the forms etc for DegreeProgram in filament but it looks ugly having it on the navigation menu. Within the DegreeResource I have a relationmanager for programs and would like to have the create and edit actions from that relation manager redirected to the create and edit forms for the DegreeProgramResource instead, while leaving the attach/deteach actions link the the original relationship. I tried editing the relationship manager to use the other form but that threw this error
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given.
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given.
So then I tried mutating the data being sent to the form like this
->mutateRecordDataUsing(fn (array $data): array => [
$data = DegreeProgram::where('program_id', $data['program_id'])->where('degree_id', $data['degree_id'])->first(),
]),
->mutateRecordDataUsing(fn (array $data): array => [
$data = DegreeProgram::where('program_id', $data['program_id'])->where('degree_id', $data['degree_id'])->first(),
]),
but that throws this error
Call to a member function getResults() on null
Call to a member function getResults() on null
Does anyone have any other ideas?
3 replies
FFilament
Created by bardolf_6969 on 9/13/2024 in #❓┊help
is it possible to open a relationship in a modal?
I have a model (property) that is the child in three one to many relationships. I want users to be able to edit the parent record for each of those relationships without having to navigate away from the property. The relationship is currently being set via a select.
Originally I created a hidden subform that was displayed when the select had a value but other than refreshing the entire page I couldn't workout how to populate the data in that subform. Then I tried using a action form via the header actions in the section containing the select and that sort of works but because it is being loaded from what is available in the $record I can't see how to get all of the relation stuff (images, tags, etc.) into the modal.
27 replies
FFilament
Created by bardolf_6969 on 9/4/2024 in #❓┊help
Reload a subform after select value changes
I have a select that is setting a many-to-many relationship between my room and building records. As there are many buildings with very similar names I want to show a details panel below the select with the main details of the selected building.
I have the select working and the details panel is shown after a selection is made but the vlaues are all empty.
I'm guessing I need to repopulate those fields after the select value is changed but I don't know how to achieve this. Any suggestions on this would be hugely appreciated. I'm trying to paste the code snippet for the select and details section but discord wants to make it an attachment for some reason.
2 replies
FFilament
Created by bardolf_6969 on 8/11/2024 in #❓┊help
Unable to upload multiple images at the same time
When I try to upload more than one image to my SpatieMediaLibraryFileUpload component it returns a 422 error with the following response
{"message":"validation.uploaded","errors":{"files.0":["validation.uploaded"]}}
{"message":"validation.uploaded","errors":{"files.0":["validation.uploaded"]}}
If I then save it will have saved the first image I uploaded.
If I upload multiple images, one at a time and save the resources between each upload they work fine.
I'm using filament/spatie-laravel-media-library-plugin v3.2.92
6 replies
FFilament
Created by bardolf_6969 on 7/12/2024 in #❓┊help
If a relationship is hidden on a resource form does filament still try to submit it?
I have a resource form that when no relationship is set displays a select box but that changes to a section displaying the details once the relationship is set. The problem is when submitting the form I'm getting an error that a null value in the relation violates not-null constraint. Below is the section of the form
Forms\Components\Select::make('user_id')
->hidden(fn (Get $get) => !empty($get('user_id')))
->columnStart(1)
->columnSpan(2)
->label('Owner')
->options(User::all()->pluck('name', 'id'))
->searchable()
->live(),
Forms\Components\Section::make('Owner Information')
->hidden(fn (Get $get) => empty($get('user_id')))
->columnSpan(2)
->relationship('owner')
->schema([
Forms\Components\Section::make('Basic Information')
->columns(2)
->schema([
Forms\Components\TextInput::make('name')
->label('Full Name')
->columnSpan(2)
->maxLength(255),
Forms\Components\TextInput::make('phone')
->tel()
->maxLength(255),
Forms\Components\TextInput::make('email')
->email()
->maxLength(255),
])
->reactive(),
Forms\Components\Section::make('Social Media')
->columns(3)
->schema([
Forms\Components\TextInput::make('line_id')
->maxLength(255)
->reactive(),
Forms\Components\TextInput::make('facebook')
->maxLength(255)
->reactive(),
Forms\Components\TextInput::make('whatsapp')
->maxLength(255)
->reactive(),
]),
])
->reactive(),
Forms\Components\Select::make('user_id')
->hidden(fn (Get $get) => !empty($get('user_id')))
->columnStart(1)
->columnSpan(2)
->label('Owner')
->options(User::all()->pluck('name', 'id'))
->searchable()
->live(),
Forms\Components\Section::make('Owner Information')
->hidden(fn (Get $get) => empty($get('user_id')))
->columnSpan(2)
->relationship('owner')
->schema([
Forms\Components\Section::make('Basic Information')
->columns(2)
->schema([
Forms\Components\TextInput::make('name')
->label('Full Name')
->columnSpan(2)
->maxLength(255),
Forms\Components\TextInput::make('phone')
->tel()
->maxLength(255),
Forms\Components\TextInput::make('email')
->email()
->maxLength(255),
])
->reactive(),
Forms\Components\Section::make('Social Media')
->columns(3)
->schema([
Forms\Components\TextInput::make('line_id')
->maxLength(255)
->reactive(),
Forms\Components\TextInput::make('facebook')
->maxLength(255)
->reactive(),
Forms\Components\TextInput::make('whatsapp')
->maxLength(255)
->reactive(),
]),
])
->reactive(),
4 replies
FFilament
Created by bardolf_6969 on 6/27/2024 in #❓┊help
Custom page with a wizard form
Ok only started using Filament this week, so forgive me if I'm missing something very basic. I'm trying to create a custom page with a wizard form component. I've got that working but when I try to add a select to the first page of the wizard based on a relationship in the model I get an error message
Call to a member function isRelation() on null
Call to a member function isRelation() on null
7 replies
FFilament
Created by bardolf_6969 on 6/26/2024 in #❓┊help
Customizing the Registration Page
Rather than a single name field I need my User model to have 3 seperate name fields (first_name, middle_names, last_name). I've followed the example, in the docs, of extending filaments builtin registration class and overriding the form method. This works fine and changes the form but when I try to use it I get an error that the route doesn't accept POST requests. I then tried overriding the getForms method instead of the form method thinking that maybe skipping straight to the form something was being missed but the result was the same. Can anyone tell me what I'm doing wrong?
3 replies
FFilament
Created by bardolf_6969 on 6/24/2024 in #❓┊help
Use value from first select filter to limit results in second select filter
I've got the standard city, state, country setup and can access all the relevant details in the table itself.
What I'm hoping to do is in the city table I have 2 select filters. 1 for country and one for state. I'd like it so that once they select a country it reduces the options in the state select to only have states from that country. I know I can customize the relationship callback for the select filter but how can I access the value selected in the first select?
6 replies