[Feature] Attributes in pivot tables
See original GitHub issueBug report
What I did
Trying to create Attach/Detach between two entities connected with M:N relation (pivot table has additional attributes).
I’ve tried couple of different field types (select2_multiple, select_multiple), i even tried to create repeatable field.
Having attributes in pivot tables is like really common (don’t recall project when i didn’t have this)…
What I expected to happen
To be able to specify pivot attributes for each entity i select in select2_multiple, or to have a way to add some custom button with modal where you can attach relation with some additional attrbutes.
What happened
When i was using select_multiple or select2_multiple, additional fields were not showing and application was throwing exceptions (as expected).
When i was trying to use repeatable, data sent to server was in json format, and syncPivot method wasn’t well coded to handle this.
What I’ve already tried to fix it
I’ve just tried different field types.
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version
the output is:
PHP VERSION:
PHP 7.4.3 (cli) (built: Feb 18 2020 17:29:46) ( ZTS Visual C++ 2017 x64 ) Copyright © The PHP Group Zend Engine v3.4.0, Copyright © Zend Technologies with Xdebug v2.9.3, Copyright © 2002-2020, by Derick Rethans
LARAVEL VERSION:
v7.12.0@c2fff1e9879494a6f853593b3c517dc9922bbb51
BACKPACK VERSION:
4.1.6@cbd4143d3eb8302916012af205565cd3183f274f
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Hello guys.
Indeed this is something we have discussed and probably we will attempt to provide a solution for this.
I have corretly labeled it, and will have a discussion with @tabacitu about this.
Repeatable https://backpackforlaravel.com/docs/4.1/crud-fields#repeatable might work in this scenario, because you can intercept the request in controller and do whatever you want with it.
Maybe what is missing here is to set the max items a repeatable field can have, so you can set it to only one, am i right ? @Dzale ?
Backpack is adding features all the time, i think they will handle this fast. 😉
If you are in big hurry you can checkout https://voyager.devdojo.com , not sure if they have the same problem…