From 0c4a3e9d98c57f36bc21e6fff78c9ec56b5f0cd3 Mon Sep 17 00:00:00 2001 From: Ned Zimmerman Date: Thu, 9 Nov 2023 14:04:52 -0700 Subject: [PATCH] feat: prevent editing of page titles --- .../Resources/PageResource/Pages/EditPage.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/Filament/Resources/PageResource/Pages/EditPage.php b/app/Filament/Resources/PageResource/Pages/EditPage.php index ea2ab7d89..3e8b509fd 100644 --- a/app/Filament/Resources/PageResource/Pages/EditPage.php +++ b/app/Filament/Resources/PageResource/Pages/EditPage.php @@ -5,12 +5,44 @@ use App\Filament\Resources\PageResource; use App\Models\Page; use Filament\Actions; +use Filament\Forms; +use Filament\Forms\Form; use Filament\Resources\Pages\EditRecord; class EditPage extends EditRecord { protected static string $resource = PageResource::class; + public function form(Form $form): Form + { + return $form + ->schema([ + Forms\Components\TextInput::make('title.en') + ->label(__('Page title').' ('.get_language_exonym('en').')') + ->disabled(), + Forms\Components\TextInput::make('title.fr') + ->label(__('Page title').' ('.get_language_exonym('fr').')') + ->disabled(), + Forms\Components\MarkdownEditor::make('content.en') + ->disableToolbarButtons(['attachFiles']) + ->label(__('Content').' ('.get_language_exonym('en').')') + ->helperText(__('The following values will be expanded in the output: ":home", ":email", ":tos" and ":privacy_policy". You may wrap these values in "<>" to display the URL itself.')) + ->columnSpan(2), + Forms\Components\MarkdownEditor::make('content.fr') + ->disableToolbarButtons(['attachFiles']) + ->label(__('Content').' ('.get_language_exonym('fr').')') + ->helperText(__('The following values will be expanded in the output: ":home", ":email", ":tos" and ":privacy_policy". You may wrap these values in "<>" to display the URL itself.')) + ->columnSpan(2), + ]); + } + + protected function mutateFormDataBeforeSave(array $data): array + { + unset($data['title']); + + return $data; + } + protected function getHeaderActions(): array { return [