2

Is it possible to use Laravel Backpack relationship field type with both inline_create and pivot fields enabled?

I'm trying to make this happen:

I have 2 entities, Products and Productions, and both have a belongsToMany relation defined in the model. Therefore they have a pivot table with product_id and production_id. In this pivot table I have a count column.

With Backpack I'm trying to solve the following: I want to fetch products on productions create operation, or create product from this view and specify the pivot field count with it.

If I remove the 'subfields' property from the field definition, the add field button shows up.

I've attached 3 screenshots of the mentioned functionality.

Product with Add, but without count field

Clicked on "Add" - Modal opened

Product with count pivot field and without Add

Laurel
  • 5,965
  • 14
  • 31
  • 57

1 Answers1

2

Hello @roamingTurkey !

You should be able to do it, but you need to configure your pivotSelect key in your n-n field definition : https://backpackforlaravel.com/docs/5.x/crud-how-to#extra-saving-additional-attributes-to-the-pivot-table

Let me know!

Pedro X
  • 849
  • 5
  • 13