File upload not returning url after upload

I created a form to send a message and attach files, the files upload, but the he data that comes back shows nothing for the data uploaded, so it is returning an empty array I can't figure out why this happens, please help code: Form:
->form([
TextInput::make('to')->default($this->->user->name.' ('.$this->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')
->directory(fn ($record) => 'message_attachments/'.$record->id)->visibility('private')->multiple()
]),
->form([
TextInput::make('to')->default($this->->user->name.' ('.$this->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')
->directory(fn ($record) => 'message_attachments/'.$record->id)->visibility('private')->multiple()
]),
Action:
->action(function ($data): void {
dd($data);
...
->action(function ($data): void {
dd($data);
...
DD output:
array:3 [▼ // app\Filament\Pages\Message.php:55
"subject" => "aa"
"message" => "a"
"files" => []
]
array:3 [▼ // app\Filament\Pages\Message.php:55
"subject" => "aa"
"message" => "a"
"files" => []
]
Env:
FILAMENT_FILESYSTEM_DISK=local
FILAMENT_FILESYSTEM_DISK=local
No description
19 Replies
LeandroFerreira
LeandroFerreira10mo ago
FileUpload::make('files')->dehydrated()... ?
bakriawad
bakriawadOP10mo ago
Didn't work, still empty array is returned
LeandroFerreira
LeandroFerreira10mo ago
How are you filling the fields? Are you uploading a new file or filling it from the record? Where are you using this form?
bakriawad
bakriawadOP10mo ago
uploading new files, attachments to an email/message I am unsure where they should save, searched PC for the files but nothing appears the files are selected then uplaoded via the FileUpload form component the form is on a button, executed on click, and is a page Action
Action::make('Message')
->action(function ($data): void {
dd($data);
...
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
...
Action::make('Message')
->action(function ($data): void {
dd($data);
...
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
...
LeandroFerreira
LeandroFerreira10mo ago
Share the whole code you are trying to do
bakriawad
bakriawadOP10mo ago
Action::make('Message')
->action(function ($data): void {
dd($data);

$message = [
'from_user_id' => auth()->user()->id,
'to_user_id' => $this->patient->user->id,
'type' => 'patient',
'subject' => $data['subject'],
'message' => $data['message'],
'created_at' => now(),
];

MessageService::createMessages([$message]);
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
TextInput::make('to')->default($this->patient->user->name.' ('.$this->patient->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')->disk('local')
->directory(fn ($record) => 'message_attachments/'.$record->id)->visibility('private')->multiple()
->preserveFilenames()->dehydrated()
]),
Action::make('Message')
->action(function ($data): void {
dd($data);

$message = [
'from_user_id' => auth()->user()->id,
'to_user_id' => $this->patient->user->id,
'type' => 'patient',
'subject' => $data['subject'],
'message' => $data['message'],
'created_at' => now(),
];

MessageService::createMessages([$message]);
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
TextInput::make('to')->default($this->patient->user->name.' ('.$this->patient->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')->disk('local')
->directory(fn ($record) => 'message_attachments/'.$record->id)->visibility('private')->multiple()
->preserveFilenames()->dehydrated()
]),
I need to upload files from here, and capture it, but the files aren't captured. the messages are created, this whole code works... just that the file upload doesn't
LeandroFerreira
LeandroFerreira10mo ago
Actions\Action::make('Message')
->action(function ($data): void {
dd($data);
})
->form([
FileUpload::make('files')->label('Attachments')
->disk('local')
])
Actions\Action::make('Message')
->action(function ($data): void {
dd($data);
})
->form([
FileUpload::make('files')->label('Attachments')
->disk('local')
])
this should show the files
bakriawad
bakriawadOP10mo ago
I tried that before, didn't work. Let me try
LeandroFerreira
LeandroFerreira10mo ago
Where are you using this action?
bakriawad
bakriawadOP10mo ago
On a page Livewire component sitting in a filament page
bakriawad
bakriawadOP10mo ago
No description
bakriawad
bakriawadOP10mo ago
No description
bakriawad
bakriawadOP10mo ago
No description
LeandroFerreira
LeandroFerreira10mo ago
share the whole code
bakriawad
bakriawadOP10mo ago
<?php

namespace App\Filament\Pages;


use App\Services\MessageService;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Actions\Action;
use Filament\Pages\Page;

class Patient extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.patient';
protected static ?string $title = 'Patient profile';
protected static ?string $slug = 'patient/{patientId}/{currentTab?}';
public $patientId;
public $patient;
public $tabs = [];
public $currentTab = 'tab1';
public $subTab = 'subTab1';


protected function getHeaderActions(): array
{
return [
Action::make('Message')
->action(function ($data): void {
dd($data);

$message = [
'from_user_id' => auth()->user()->id,
'to_user_id' => $this->patient->user->id,
'type' => 'patient',
'subject' => $data['subject'],
'message' => $data['message'],
'created_at' => now(),
];

MessageService::createMessages([$message]);
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
TextInput::make('to')->default($this->patient->user->name.' ('.$this->patient->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')->disk('local')
]),
];
}



public function getTitle(): string
{
return "Test Page";
}
<?php

namespace App\Filament\Pages;


use App\Services\MessageService;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Pages\Actions\Action;
use Filament\Pages\Page;

class Patient extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.patient';
protected static ?string $title = 'Patient profile';
protected static ?string $slug = 'patient/{patientId}/{currentTab?}';
public $patientId;
public $patient;
public $tabs = [];
public $currentTab = 'tab1';
public $subTab = 'subTab1';


protected function getHeaderActions(): array
{
return [
Action::make('Message')
->action(function ($data): void {
dd($data);

$message = [
'from_user_id' => auth()->user()->id,
'to_user_id' => $this->patient->user->id,
'type' => 'patient',
'subject' => $data['subject'],
'message' => $data['message'],
'created_at' => now(),
];

MessageService::createMessages([$message]);
})->icon('heroicon-o-envelope')->label('Message')->modalButton('Send Message')->modalHeading(request()->input('id'))
->form([
TextInput::make('to')->default($this->patient->user->name.' ('.$this->patient->user->email.')')->disabled(),
TextInput::make('subject')->required(),
Textarea::make('message')->required(),
FileUpload::make('files')->label('Attachments')->disk('local')
]),
];
}



public function getTitle(): string
{
return "Test Page";
}
this is basically the whole thing.. there is a mount and change tab function, neither should have any effect
LeandroFerreira
LeandroFerreira10mo ago
protected function getHeaderActions(): array
{
return [
Action::make('Message')
->action(function ($data): void {
dd($data);
})
->form([
FileUpload::make('files')->label('Attachments')->disk('local')
])
];
}
protected function getHeaderActions(): array
{
return [
Action::make('Message')
->action(function ($data): void {
dd($data);
})
->form([
FileUpload::make('files')->label('Attachments')->disk('local')
])
];
}
No description
bakriawad
bakriawadOP10mo ago
am I missing a config or something??
LeandroFerreira
LeandroFerreira10mo ago
I don't know, maybe you can try it in another fresh install
bakriawad
bakriawadOP10mo ago
I will try that
Want results from more Discord servers?
Add your server