update record
$form->embeds('content', '', function ($form) {
$form->image('logo');
});
all ok, file field is saved
next, bug example
$form->embeds('content', '', function ($form) {
$form->image('logo');
$form->textarea('description');
});
after update file field is clear
Do you resolve the problem?
i face the same
Yes. I wrote "hack."
But I did not initialize Git, so it's hard to say now what I'm changing.
In the next few days, I will rewrite this part. And I can answer in detail.
As long as I remember. Logic of the admin panel is. Fields are updated there, the values of which have changed.
The "file" field sends a value only when the file is uploaded. In other cases it is empty.
Hence the saved JSON, will always differ from the updated JSON. And because of this, the file disappears.
Currently, you can resolve this by using model saving event.
In your model add:
public static function boot()
{
parent::boot();
static::saving(function (Model $model) {
if(empty($model->content['logo'])) {
$content = $model->content;
$original = json_decode($model->getOriginal('content'), true);
$content['logo'] = array_get($original, 'logo');
$model->setAttribute('content', $content);
}
});
}
Can you add a parameter to the embed method to control replace or extend data?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Currently, you can resolve this by using model saving event.
In your model add: