черешня(вишня)💙💛
Edit only single record with custom page
and i would really appriciate it if you coudl help me to use this method to save data from form here "
code snippet:
<x-filament::page>
<x-filament::form submit="edit">
{{ $this->form }}
<x-filament::button type="submit">Зберегти</x-filament::button>
</x-filament::form>
</x-filament::page>
33 replies
Edit only single record with custom page
@S. Mert ÖZTÜRK thank you! i got you.
so could you please tell, did i do it right?
code snippet:
<?php
namespace App\Filament\Pages;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
class EditNotificationBoar extends Page implements HasForms
{
use InteractsWithForms;
public $json = '';
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.edit-notification-boar';
public function mount(): void
{
$arr = json_decode($this->json, true);
$this->form->fill($arr);
}
protected function getFormSchema(): array
{
return [
TextInput::make('message')
->required()
->maxLength(255)
->label(__('labels.notification_board.message'))
];
}
public function edit(): void
{
$data = $this->form->getState();
$this->json = json_encode($data);
$filePath = storage_path('app/public/data.json');
file_put_contents($filePath, $this->json);
}
}
33 replies