Is it possible to add an Optional Details field to a Relationship Field type in the database tool?
I think it could be nice in order to improve display options.
And also i think it would be helpful to add a link to the relationship that is provided in the model we are working (add/updating). I think that it was possible in older versions, is that right?
Hi @abacram , have you found a workaround for this issue ? thanks in advance :)
Hi,
Im just new here, i did @abacram want but its just a workaround.
Follow the steps below:
1) Create your relationship field in BREAD manager / Database.
2) Check your database (phpmyadmin) and find the row in the "data_rows" table - use search via data_type_id
3) Once found, edit the relationship field.
4) Edit the "details" field, make sure it will still be enclosed to be read as JSON.
example: {"model":"App\\projects","table":"projects","type":"belongsTo","column":"id","key":"id","label":"name","pivot_table":"categories","pivot":"0","display":{"width":"3"}}
"display":{"width":"3"}
The highlighted code is the added code to allow the Optional Details to work.
Hope this help everyone checking this.
Hi,
I'm in 1.1.1 now, and the problem persists. If you add width to the details field manually in the data_rows table it works, but when bread is updated, width is gone.
Digging in the code, I found out that DataType::getRelationships called in DataType::updateDataType overwrites the content without having in mind "extra details".
The details @MrCrayon explained in #2874 saying that this was fixed with that commit seem wrong to me (maybe it was like that in 1.0), because now it is managed by VoyagerBreadController and there is no such call to that function.
I believe one solution would be to add a new field in the relationship part (see images) to add options like in the other data_rows.


And then merge those options with the ones related to the relationship.
Another solution, maybe easier, would be to use details of the relationship field (the FK, actually) to have those details, because in this case the field is removed from the view with that function (removeRelationshipField). In the bread editor the FK field has the JSON editor and the options are saved correctly in the "details" field.
I don't know which is the way to go, or it would be better doing it differently. Voyager guys maybe can shout their opinions....
I'm pretty new to all this (laravel+Voyager), but maybe I'll try to do a fork and PR with this change :)
Hope I explained myself! Cheers!!
X.
PR #2874 was not accepted that's why problem is not fixed.
BTW #2874 solved the problem using details from the field referenced in relationship field, so it does nothing to preserve details in relationship edited manually if you use gui to edit that bread again.
I have a pending PR to resolve this issue.
https://github.com/the-control-group/voyager/pull/3314
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment
Hi,
Im just new here, i did @abacram want but its just a workaround.
Follow the steps below:
1) Create your relationship field in BREAD manager / Database.
2) Check your database (phpmyadmin) and find the row in the "data_rows" table - use search via data_type_id
3) Once found, edit the relationship field.
4) Edit the "details" field, make sure it will still be enclosed to be read as JSON.
example:
{"model":"App\\projects","table":"projects","type":"belongsTo","column":"id","key":"id","label":"name","pivot_table":"categories","pivot":"0","display":{"width":"3"}}"display":{"width":"3"}
The highlighted code is the added code to allow the Optional Details to work.
Hope this help everyone checking this.