© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
16 replies
Zyel

Access other field value for store at relationship form

return $form
->schema([
Group::make([
Section::make('article')
->schema([
TextInput::make('title'),
FileUpload::make('thumbnail'),
RichEditor::make('content'),
]),

Section::make('published')
->relationship('published')
->schema([
DatePicker::make('publish_date'),
Radio::make('edited_status')
->options([
'drafted' => 'drafted',
'completed' => 'completed',
'archived' => 'archived',
]),
Radio::make('publish_status')
->options([
'queue' => 'queue',
'preview' => 'preview',
'publish' => 'publish'
]),
])
->mutateRelationshipDataBeforeCreateUsing(function (array $data, Model $record): array {
$edited_history = [
'title' => $record['title'],
'content' => $record['content'],
'thumbnail' => $record['thumbnail'],
];
$data['edited_history'] = $edited_history;
$data['stakeholder_id'] = auth()->id();
return $data;
})
->mutateRelationshipDataBeforeSaveUsing(function (array $data, Model $record): array {

// can't access $data['title']

$edited_history = [
'title' => $record['title'],
'content' => $record['content'],
'thumbnail' => $record['thumbnail'],
];

// i want merge and store as json for history

$data['edited_history'] = $edited_history;
$data['stakeholder_id'] = auth()->id();
return $data;
})
]),
]);

// cannot access $data['title'] at mutateRelationshipDataBeforeSaveUsing() function
// or any approach for this?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Wizard form get other input value field
FilamentFFilament / ❓┊help
3y ago
Form field value based on 2 other fields
FilamentFFilament / ❓┊help
13mo ago
Setting value of relationship form field via $set closure
FilamentFFilament / ❓┊help
3y ago
->relationship() on form field directly?
FilamentFFilament / ❓┊help
4mo ago