Copy contents of first repeater fields to another
I am creating form having address fields of users. Each repeater item contains address fields of one user.
Now I want to create a button which will copy the data of address fields from first repeater item and paste it into relevant fields of other repeater.
As per my understandings, we need copy the state of fields that I wanted, but can't figure out how do I copy and paste it to other fields.
9 Replies
Use
$get
with $set
@krekas Can you please show me how. Let say this is my code inside repeater
Forms\Components\Textarea::make('home_address.address1')
->label('Address 1')
->required(),
Forms\Components\Textarea::make('home_address.address2')
->label('Address 2'),
Can you not use cloneable()? https://filamentphp.com/docs/3.x/forms/fields/repeater#cloning-items
@awcodes Not exactly. Because I don't want to copy the data of all fields, only few fields data are required to get copied.
So create action which will get the values and set them in the next repeater
$get('..\fieldname')
@krekas Can you please show me how to do this?
How can I show what I don't have? First try yourself
Yo,
So Mr. Luffy, Can you show me how to do this, a code snippet will be more helpful.
Ok let me try