Avoid ID in edit page

I need to use the edit page of my plugin without the ID is it possible?
'edit' => Pages\EditSettings::route('/{record}/edit'),
should be
'edit' => Pages\EditSettings::route('/edit'),
'edit' => Pages\EditSettings::route('/{record}/edit'),
should be
'edit' => Pages\EditSettings::route('/edit'),
thanks
16 Replies
ChesterS
ChesterS6d ago
How would you know which record to edit?
Roland Barkóczi
I’d use a custom page for this purpose
ChesterS
ChesterS6d ago
Ok but how would you pass the id of record you want to edit?
Soundmit
Soundmit6d ago
I don't need to pass an ID. I've built a custom settings management system as part of a larger plugin. It features a single form that saves each setting as a separate row in a database table. In the end, this results in around 30 rows. When editing, I want to update all the rows simultaneously. I know I can create a custom page in Filament, but since I'm developing a plugin, I haven’t found detailed information on how to build a custom page within the plugin rather than using the default list/create/edit pages. is it possible to use custom pages i plugin?
toeknee
toeknee6d ago
Just use a standard page and not an edit page.
ChesterS
ChesterS6d ago
Even with that, there must be something that connects those 30 rows right? How would you know which 30 to edit. Anyway, There's no magic here, the pages are just routes - you can pass w/e you want to the page - but I don't think Filament will work out-of-the-box for you. Maybe look into things like Sushi https://github.com/calebporzio/sushi (a tutorial of sorts on how to use it https://laraveldaily.com/post/filament-load-table-data-from-3rd-party-api)
Soundmit
Soundmit6d ago
Even with that, there must be something that connects those 30 rows right? nope, they are just settings that i want to use in the frontend (i'm developing a custom frontend solution for filament)
lukevi
lukevi5d ago
In that case - a repeater could probably do what you want. If settings is a table, make it a relation to something like User, as in User::hasMany('settings'). Then the user/edit page can list every setting, available to edit, and save all with one submit.
Soundmit
Soundmit5d ago
i understand but this is a collection of settings related to the website's frontend, like logo, site name, description, seo... i've tried to used a pair of filament's settings plugin but i need multi language settings and they doesn't support translations
toeknee
toeknee5d ago
So just use a custom Filament Page?
Soundmit
Soundmit5d ago
Yes, I know how to do this, but I would like to create a plugin so that when it's installed, it creates the table, etc. Is there a way to create a page within the plugin or to make the plugin itself create the page for me?
toeknee
toeknee5d ago
Tha towuld be custom page method no?
lukevi
lukevi4d ago
Then create the relationship like Models\Frontend::hasMany('settings'). Sure the relationship may be unnecessary, but the benefit is the Filament repeater can work with it easily.
Soundmit
Soundmit4d ago
it works! - made a settings page in the plugin with form and the other methods - added this to the form
->statePath('data')
->model(SettingModel::class);
->statePath('data')
->model(SettingModel::class);
registered the page
public function register(Panel $panel): void
{
$panel
->pages([
SettingsPage::class,
]);
}
public function register(Panel $panel): void
{
$panel
->pages([
SettingsPage::class,
]);
}
Want results from more Discord servers?
Add your server