I have one-to-many relationship tables. I want to store all my data in one form. Therefore, I created a nested form in parent controller. I have a number of images, which each image has caption text. In adding a new record, it inserts all inputs with image paths to the table fields. it means it saves all image paths in the database.
But the problem is when I go to edit action. After I submitted the edit form the image path value of child table table went to null.
`class Flag extends Model
{
protected $table = 'flags';
protected $fillable =[
'small_description',
'cover_photo',
'cover_photocaption',
];
public function flagimage()
{
return $this->hasMany(Flagimage::class, 'flag_id', 'id');
}
}`
`class Flagimage extends Model
{
protected $table = 'flagimages';
protected $fillable = [
'flag_id',
'image_url',
'image_caption',
];
public function flag()
{
return $this->belongsTo(Flag::class, 'flag_id', 'id');
}
Description:
I have one-to-many relationship tables. I want to store all my data in one form. Therefore, I created a nested form in parent controller. I have a number of images, which each image has caption text. In adding a new record, it inserts all inputs with image paths to the table fields. it means it saves all image paths in the database.
But the problem is when I go to edit action. After I submitted the edit form the image path value of child table table went to null.
`class Flag extends Model { protected $table = 'flags';
}`
`class Flagimage extends Model { protected $table = 'flagimages';
}`
`$form = new Form(new Flag());
Steps To Reproduce: