Zyel
RepeatableEntry not loop when inside scheme contain Sections
when i try repeatable entry with section inside, its only repeat the first object
this the code:
RepeatableEntry::make('published.edited_history')->schema([
ComponentsSection::make('history')->schema([
TextEntry::make('modify_at'),
TextEntry::make('article_category'),
TextEntry::make('title')->label('Judul Artikel'),
ImageEntry::make('thumbnail')->label('Gambar Cover'),
TextEntry::make('content')->html()->columnSpanFull(),
])
]),
7 replies
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?
17 replies