files not previewed when form is pre-filled with data
I have a form which has the following schema
and there is a button that when I clicked some data is pre-filled on this form. Here is how that is done.
and here is the data shown before getting filled into the form (shown on the picture).
protected function getEditBillItemFormSchema(): array
{
return [
Forms\Components\Card::make([
// Input::medicalBillType('type', $this->bill_items->pluck('type')->toArray())->reactive()->disabled(),
Forms\Components\TextInput::make('type')->disabled(),
Input::decimalInput('fee')->required(),
Forms\Components\DatePicker::make('date_of_care')
->visible(fn (\Closure $get) => $get('type') === 'physication')
->required(),
Forms\Components\Textarea::make('description')->rows(2)->cols(20)
->nullable()->maxLength(250)->columnSpanFull(),
FileUpload::make('attachments')->multiple()->directory(fn (\Closure $get) => $get('type'))->columnSpanFull(),
// Input::fileUpload('attachments')->directory(fn (\Closure $get) => $get('type'))->columnSpanFull(),
])->columns(2),
];
}
protected function getEditBillItemFormSchema(): array
{
return [
Forms\Components\Card::make([
// Input::medicalBillType('type', $this->bill_items->pluck('type')->toArray())->reactive()->disabled(),
Forms\Components\TextInput::make('type')->disabled(),
Input::decimalInput('fee')->required(),
Forms\Components\DatePicker::make('date_of_care')
->visible(fn (\Closure $get) => $get('type') === 'physication')
->required(),
Forms\Components\Textarea::make('description')->rows(2)->cols(20)
->nullable()->maxLength(250)->columnSpanFull(),
FileUpload::make('attachments')->multiple()->directory(fn (\Closure $get) => $get('type'))->columnSpanFull(),
// Input::fileUpload('attachments')->directory(fn (\Closure $get) => $get('type'))->columnSpanFull(),
])->columns(2),
];
}
public function editBillItem($index)
{
$this->currentEditIndex = $index;
$this->editData = $this->bill_items[$index];
$this->editBillItemForm->fill([
'type' => $this->editData['type'],
'fee' => $this->editData['fee'],
'date_of_care' => $this->editData['date_of_care'] ?? '',
'description' => $this->editData['description'],
'attachments' => $this->editData['attachments'],
]);
}
public function editBillItem($index)
{
$this->currentEditIndex = $index;
$this->editData = $this->bill_items[$index];
$this->editBillItemForm->fill([
'type' => $this->editData['type'],
'fee' => $this->editData['fee'],
'date_of_care' => $this->editData['date_of_care'] ?? '',
'description' => $this->editData['description'],
'attachments' => $this->editData['attachments'],
]);
}
1 Reply
and I am showing the form in a blade file. here is where the form is shown.
The issue is that even the form is filled with the data given to it, it does not preview the attachments. It fill all the other fields through.
<x-filament::modal id="custom-modal-handle" width='4xl'>
{{-- <x-filament::button wire:click="editBillItem({{ $bill_item->type }})">
Update
</x-filament::button> --}}
<x-slot name="header">
Edit Medical Bill
</x-slot>
<x-filament::form wire:submit.prevent="saveEditedBillItem">
<div >
{{$this->editBillItemForm}}
<x-filament::button type="submit" x-on:click="$dispatch('close-modal', {id: 'custom-modal-handle'})">
Update
</x-filament::button>
</div>
</x-filament::form>
</x-filament::modal>
<x-filament::modal id="custom-modal-handle" width='4xl'>
{{-- <x-filament::button wire:click="editBillItem({{ $bill_item->type }})">
Update
</x-filament::button> --}}
<x-slot name="header">
Edit Medical Bill
</x-slot>
<x-filament::form wire:submit.prevent="saveEditedBillItem">
<div >
{{$this->editBillItemForm}}
<x-filament::button type="submit" x-on:click="$dispatch('close-modal', {id: 'custom-modal-handle'})">
Update
</x-filament::button>
</div>
</x-filament::form>
</x-filament::modal>