open-admin
open-admin copied to clipboard
MorphMany relation problem on dynamic NestedForm
Describe the bug When you create morphMany relation to another table and use it main table to create dynamic forms everything is working except image update. If you add second form image then first forms image is disappearing from database and set it to 0 value.
I have Home model and Slider model Code example: in HomePageController in Admin folder of open-admin admin panel.
protected function form()
{
$form = new Form(new Home());
$form->tab('General', function ($form) {
$form->text('seo_title_az', __('Seo title az'));
$form->textarea('seo_desc_az', __('Seo desc az'));
$form->text('seo_title_en', __('Seo title en'));
$form->textarea('seo_desc_en', __('Seo desc en'));
$form->text('slug', __('Slug'));
});
$form->tab('Slider', function ($form) {
$form->morphMany('sliders', function (Form\NestedForm $form) {
$form->text('title_en');
$form->textarea('desc_en');
$form->image('image_first', __('First image'));
$form->image('image_second', __('Second image'));
$form->radio('active', __('Active'))->options([
1 => 'Active',
0 => 'Inactive',
])->default(1);
});
});
return $form;
}
}
System
- Open-admin version ^1.0
- PHP version 8.1
- Laravel Version 10
- OS: [Linux]
- Browser [firefox]