Closed WrdVdb closed 3 months ago
Hey @WrdVdb Thanks for your input to enhance the relationship field.
The relationship field covers other types of relationships which don't act as repeatable. This makes me think not to opt for rows
options, But yes limiting selection to particular items looks sensible, which i currently possible at server-side validation only. On the client side, this could be a better experience but covering this feature on all types of relationships would not be this simple.
@pxpm @tabacitu what are your thoughts on it?
Hello @karandatwani92 and @WrdVdb
Thanks for the inputs here 🙏
The reason why we removed that ability is because it does not make a good UX experience. Usually what happened is that empty relations were created, polluting the db.
In my understanding it makes a better UX to make it mandatory in Validation, with the min/max you need and the user would know that he need to add that relation if validation fails.
I think we can get to a middle-ground here. @karandatwani92 can you investigate the possibility of having the defaults we currently have but allow the developer to overwrite them at their own responsibility ?
Not the min,max rows, that we cannot make as @WrdVdb suggested, we would force everyone to define a min/max otherwise it would be 0. Min 0 is fine, but Max 0 is not.
I think init rows = min rows ?? 0
it's the optimal extensibility here: https://github.com/Laravel-Backpack/PRO/blob/28a07bc23cf572eef9b3d0133b565c56929e98bb/resources/views/fields/relationship/entries.blade.php#L12
Let me know, cheers.
This was already done, sorry this issue slipped through the cracks.
I've now added it also to the "single editable relationships" 👍
Thanks again for the suggestion @WrdVdb 👍
Feature Request
What's the feature you think Backpack should have?
The relationship field use the the same repeatable field blade files. The repeatable field allows init_rows, max_rows and min_rows settings. But this is fixed default to 0 for a relationship field.
Have you already implemented a prototype solution, for your own project?
Yes, changing this (in vendor/backpack/pro/resources/views/fields/relationship/entries.blade.php)
$field['init_rows'] = 0;
to
$field['init_rows'] = $field['init_rows'] ?? $field['min_rows'] ?? 0; $field['max_rows'] = $field['max_rows'] ?? 0; $field['min_rows'] = $field['min_rows'] ?? 0;
Makes it work
Do you see this as a core feature or an add-on?
Yes, the same behaviour as the repeatable field.