Skip to content

Commit

Permalink
feat: prevent editing of page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
greatislander committed Nov 9, 2023
1 parent 3865b02 commit 0c4a3e9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/Filament/Resources/PageResource/Pages/EditPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 39 in app/Filament/Resources/PageResource/Pages/EditPage.php

View check run for this annotation

Codecov / codecov/patch

app/Filament/Resources/PageResource/Pages/EditPage.php#L39

Added line #L39 was not covered by tests
{
unset($data['title']);

Check warning on line 41 in app/Filament/Resources/PageResource/Pages/EditPage.php

View check run for this annotation

Codecov / codecov/patch

app/Filament/Resources/PageResource/Pages/EditPage.php#L41

Added line #L41 was not covered by tests

return $data;

Check warning on line 43 in app/Filament/Resources/PageResource/Pages/EditPage.php

View check run for this annotation

Codecov / codecov/patch

app/Filament/Resources/PageResource/Pages/EditPage.php#L43

Added line #L43 was not covered by tests
}

protected function getHeaderActions(): array
{
return [
Expand Down

0 comments on commit 0c4a3e9

Please sign in to comment.