Replies: 1 comment
-
I think I got it. I bound these checkboxes to public properties the custom field class. Class: class EditUser extends EditRecord
{
public array $deleteDocuments = [];
public array $deleteDocumentGroups = [];
public function beforeSave () {
dump($this->deleteDocuments, $this->deleteDocumentGroups); exit();
}
} Template: <x-dynamic-component
:component="$getFieldWrapperView()"
:field="$field"
>
@foreach ($field->getDocumentGroupsDataList() as $groupData)
<div>
<div>
Delete dp & dp_parsed
<input type="checkbox" wire:model="deleteDocuments.{{ $groupData['dp']->id }}">
</div>
<div>
Delete entire group
<input type="checkbox" wire:model="deleteDocumentGroups.{{ $groupData['original']->id }}">
</div>
</div>
@endforeach
</x-dynamic-component> And after submit I see the checked values inside Probably, in final code I could use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Package
Form builder
Package Version
3.2.136
How can we help you?
Hello! I'm trying to create a custom field that send its data to the backend upon form saving.
The data has the following format:
I want to have a checkbox for "dp" record, if it is checked, then after submitting the form records "dp" and "dp_parsed" should be deleted from the database.
And a checkbox for entire group - when it is checked, "original", "dp", and "dp_parsed" (entire group) should be deleted.
The simplified template for my custom field is:
I don't really get all that LiveWire stuff, all I want is to pass "delete_documents" and "delete_document_groups" to the server and hook into process of saving data.
Problem is that because "delete_documents" and "delete_document_groups" doesn't belong to form definition, they are not available in
App\Filament\Resources\UserResource\Pages::beforeSave()
- I checked$this->data
field. And request is not injectable.ChatGPT offers some huge bedsheet, with clunky form definition, PHP handlers, LiveWire shenanigans, and JavaScript - but I suspect there is a much simpler way to do this.
Beta Was this translation helpful? Give feedback.
All reactions