Can I use two repeaters with the same relationship to manage a single relationship in Filament 4?
Tab 1
Repeater::make('riskRegistrationsInput')
->relationship('riskRegistrations')
->addActionLabel('Add Penyebab Risk')
->label('')
->required()
->schema([
RichEditor::make('risk_causes')
->label('Penyebab Risiko')
->toolbarButtons(['bold', 'bulletList', 'italic', 'orderedList', 'redo', 'undo'])
->required()
->columnSpan(3),
])
->dehydrated(false),
Tab 2
Repeater::make('riskRegistrations')
->relationship('riskRegistrations')
->addable(false)
->deletable(false)
->label('')
->schema([
Group::make([
Hidden::make('risk_causes')
->label('Penyebab Risiko')
->dehydrated(true)
->afterStateHydrated(fn (Hidden $component, $state) => $state ? $component->state(RichContentRenderer::make($state)->toHtml()) : null),
Select::make('risk_type_status')
->label('Tipe')
->options(fn() => RiskStatus::whereIn('slug', ['accept', 'avoid', 'mitigate', 'transfer'])->pluck('title', 'slug'))
->reactive()
->required(),
TextInput::make('risk_cost')
->label('Biaya Aktivitas Risk Response (Ribu USD)')
->mask(RawJs::make('$money($input, ',', '.', 2)'))
->default(0)
->afterStateHydrated(fn ($component, $state) => $state ? $component->state(number_format($state, 2, ',', '.')) : null)
->dehydrateStateUsing(fn ($state) => (float) str_replace([',', '.'], ['.', ''], $state)),
]),
])
->itemLabel(fn($uuid, $component, $state) => strip_tags(RichContentRenderer::make($state['risk_causes'] ?? 'Risiko')->toHtml())),
0 Replies