Jack Sleight
Jack Sleight
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
Then checking for that in ->hidden()
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
Yep, adding this to my 2nd edit page works:
public function form(Form $form): Form
{
return $form->operation('edit-structure');
}
public function form(Form $form): Form
{
return $form->operation('edit-structure');
}
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
Might try to just override the operation instead, and then put it all in one form with some visibility toggles.
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
Yeah I've set up the extra page, and I have that working with a separate form by overriding getForms.
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
I could in theory use a relation manager for some of this, but the nested items actually have further nested items under them, all displayed in one big tree-like structure (only 2 ever levels), which I don't think I can do with a relation manager.
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
What I have is a standard edit page where 90% of the fields live, but this resource has a very large collection of nested data that's managed through a repeater. The repeater itself is almost entirely read-only, all of the create/edit/delete actions have been overridden to work via modals instead. And the page the repeater lives on is essentially a view page (providing an overview of all the resources nested items), but it needs to have form capabilities as the one thing you can edit through this page is the order of the nested items.
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
Not sure what you mean? This just needs to be another page with a different form, no need for frames.
14 replies
FFilament
Created by Jack Sleight on 12/6/2024 in #❓┊help
Multiple edit pages for a single resource
Overriding getForms seems to work fine, but would love to know if there is a better approach.
14 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
And it works perfectly on the nested repeaters as well.
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
I managed to get this fully working with:
->action(function (array $data, Forms\Components\Repeater $component) {
Chapter::create($data, ...);
$component->clearCachedExistingRecords();
$component->fillFromRelationship();
})
->action(function (array $data, Forms\Components\Repeater $component) {
Chapter::create($data, ...);
$component->clearCachedExistingRecords();
$component->fillFromRelationship();
})
Thanks again for your help!
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
In theory repeater works great for this, I've got the add/edit/delete/reorder working great, it's just syncing the data after the actions that's the issue.
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
It does get even more complicated, because each chapter then has a list of lessons, and ideally I want to end up with a single view where you can add/edit/delete/reorder chapters and lessons 😂
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
Ah OK, thanks I'll check that out.
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
Yeah I did try that, but I need the drag and drop re-ordering feature. May have to cook up a custom field.
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
That works, thanks! But, when you then hit save on the form it attempts to save the chapter again, which fails with a null title column error, and that somehow deletes the row that was previously added... do I need to tell it that item already exists somehow?
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
Sure. Just for context, I want to override the repeaters add action to use a modal that prompts for data and then actually creates the record. It all works perfectly, except I need the repeater to update with the newly added item.
Forms\Components\Repeater::make('chapters')
->relationship()
->label('Lessons')
->itemLabel(fn (array $state): ?string => $state['title'] ?? null)
->addActionAlignment(Alignment::Start)
->addAction(fn ($action) => $action
->form([
Forms\Components\TextInput::make('title')
->required(),
])
->action(function (Page $livewire, Course $record, array $data) {
Chapter::create([
...$data,
'course_id' => $record->id,
]);
$livewire->refreshFormData(['chapters']);
}))
Forms\Components\Repeater::make('chapters')
->relationship()
->label('Lessons')
->itemLabel(fn (array $state): ?string => $state['title'] ?? null)
->addActionAlignment(Alignment::Start)
->addAction(fn ($action) => $action
->form([
Forms\Components\TextInput::make('title')
->required(),
])
->action(function (Page $livewire, Course $record, array $data) {
Chapter::create([
...$data,
'course_id' => $record->id,
]);
$livewire->refreshFormData(['chapters']);
}))
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
Perfect thanks
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
That works, but refreshFormData doesn't seem to be doing anything. I'm trying to refresh a relationship (displayed as a repeater). Any ideas?
21 replies
FFilament
Created by Jack Sleight on 12/3/2024 in #❓┊help
Refresh page data from resource form action
Ah ha, thanks! I tried $page. Is there a list of everything that can be passed to those closures somewhere?
21 replies
FFilament
Created by Jack Sleight on 11/29/2024 in #❓┊help
Adding actions to table group rows
OK no worries, maybe I can override the group row view? Assuming it has it's own view. I'll give it a try.
5 replies