I can't use InlineCreate Operation for the case of HasMany relationship in laravel backpack 5.
I've a page for creating new item group which will allow to add multiple attributes and multiple attribute values for each corresponding attribute.
ItemGroup
model has following function
public function attributes(): HasMany
{
return $this->hasMany(Attribute::class);
}
Attribute
model has following function
public function attributeValues(): HasMany
{
return $this->hasMany(AttributeValue::class);
}
Item group creation page: https://i.postimg.cc/zfdV7JhB/Screen-Shot-2023-03-06-at-1-47-20-PM.png
In ItemGroupCrudController, I tried to add the following code block to achieve inline creation of Attribute values. But this did nothing.
use InlineCreateOperation;
...
...
protected function setupCreateOperation(): void
{
...
$this->crud->addField([
'name' => 'attributes',
'type' => "relationship",
'subfields' => [
[
'name' => 'name',
'label' => "Attribute",
'wrapper' => ['class' => 'form-group col-md-6']
],
[
'name' => 'attributeValues',
'label' => "Values",
'wrapper' => ['class' => 'form-group col-md-6']
'type' => "relationship",
'ajax' => true,
'inline_create' => true,
]
],
]);
The reason I guess inline create operation does not work for HasMany relation.
Please suggest a solution.