F
Filament3mo ago
blink

Relationship repeater fields are reset when clicking save button, but saves actually.

When I update form fields (including repeater part) and submit, repeater fields returns to old values. But data is updated in database. When I refresh page repeater fields are filled with fresh records. I found out that when save button is clicked firstly form data is saved after that relationship data is saved But when form is saved all fields are refreshed including repeater values, but at this time relationship is not updated yet and its field are filled with old values. So, how can I make repeater fields not to return to old values when save button is clicked?
7 Replies
blink
blink3mo ago
Up pls
Dennis Koch
Dennis Koch3mo ago
Can you share a video of the issue and your code?
blink
blink3mo ago
blink
blink3mo ago
TableRepeater::make('order_lines')
->label('')
->hideLabels()
->relationship('quotationLines')
->schema([
ProductSelector::make('product_id'),
TextInput::make('description'),
TextInput::make('quantity')
->required()
->label('Qty')
->numeric()
->default(1)
->live(debounce: 300),
TextInput::make('gross_price_in_cents')
->label('Gross')
->numeric()
->live(debounce: 300),
TextInput::make('discount_percentage')
->label('% Disc.')
->live(debounce: 300)
->numeric(),
TextInput::make('unit_price_in_cents')
->label('Price')
->readOnly()
->required()
->reactive(),
TextInput::make('total_price')
->required()
->readOnly(),
TextInput::make('vat_percentage')
->reactive()
->suffix('%')
->required()
->readOnly(),
])
TableRepeater::make('order_lines')
->label('')
->hideLabels()
->relationship('quotationLines')
->schema([
ProductSelector::make('product_id'),
TextInput::make('description'),
TextInput::make('quantity')
->required()
->label('Qty')
->numeric()
->default(1)
->live(debounce: 300),
TextInput::make('gross_price_in_cents')
->label('Gross')
->numeric()
->live(debounce: 300),
TextInput::make('discount_percentage')
->label('% Disc.')
->live(debounce: 300)
->numeric(),
TextInput::make('unit_price_in_cents')
->label('Price')
->readOnly()
->required()
->reactive(),
TextInput::make('total_price')
->required()
->readOnly(),
TextInput::make('vat_percentage')
->reactive()
->suffix('%')
->required()
->readOnly(),
])
This is the part of Filament resource, representing the repeater. Actually it is table repeater plugin, but I am getting the same issue when using built in repeater Same for relation manager. When you have relation manager under the from and update records within the form that are also displayed in relation manager table, relation manager table is not updated after save, until reload page manually
Dennis Koch
Dennis Koch3mo ago
Makes sense for the relation manager that you have to reload it for the new results. But it’s weird on the repeater because you already modified the data 🤔
Phil
Phil3mo ago
Same problem here. Version 3.2.70
blink
blink3mo ago
Seems to be bug? Docs say that, when we use repeater with relationship, we have to have relationship columns nullable, because first of all only form data is saved and after thet relationship data. I think, when we click submit button form data is saved and form (including repeater) is re-rendered, at this stage only form data is saved and that's why repeater values return to old data.