-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] link() helper on CrudColumn and certain CrudFields #8
Comments
Totally agree. It was talked about when we first launched 4.[ The way I see it, it would be So for Columns you'd be able to do: // if we need it to point to the CrudController
CRUD::column('category')->link(\App\Http\Controllers\Admin\CategoryCrudController::class);
CRUD::column('category')->linkTo(\App\Http\Controllers\Admin\CategoryCrudController::class);
CRUD::column('category')->linksTo(\App\Http\Controllers\Admin\CategoryCrudController::class);
// if we need it to point to the Model
CRUD::column('category')->link(\App\Models\Category::class);
// actually if what we need is the model (unlikely) we can probably guess it from the field, so it would be
CRUD::column('category`)->link();
// or
CRUD::column('category`)->withLinks(); After writing this I've realised you mentioned FIELDS not COLUMNS - and I guess we can do that for the relationship field too, indeed. Though it should probably open the link in a new tab there, to prevent the unwanted situation where the admin edits something, clicks a link to a related item, then loses all their changes. -- Thanks for raising this @selected-pixel-jameson - it's indeed a feature that will probably help out a lot. I've prioritised it so we get it done within 4.1 as a non-breaking change. Cheers! |
In terms of implementation, I see this as a convenience method on CrudColumn, just like
|
@tabacitu atm our wrapper wraps the field itself, to accomodate this we must change wrapper implementation as we did in columns to be in every selected entry instead of the whole field. |
😭 Ok then. I definitely think we should automate it for columns with a I don't know about fields, then... Will think about it... My first thought is that it's not worth rewriting the |
Technically in columns we already have the option to open each individual selected entry with their own anchor, so clicking it would render whatever link developer wants. From what I see, this |
@pxpm in columns, that's what CRUD::column('category`)->wrapper([
'href' => function ($crud, $column, $entry, $related_key) {
return backpack_url('category/'.$related_key.'/show');
},
]); you'd write: CRUD::column('category`)->link();
// or
CRUD::column('category`)->withLinks();
// or
CRUD::column('category`)->withLinksToShow();
// or
CRUD::column('category`)->linkToShow(); Or something like that, I'm not sure what the best name would be. |
@karandatwani92 let's do a prototype for: CRUD::column('category')->linkTo('category.show'); // note that this is the ROUTE NAME, not OPERATION NAME We might also add a helper (macro) for ease of use:
But not in the prototype. Let's remember to also test this on morph relationships. |
3 years later and we got it. 🙏 🥳 Reviewed. will be released in the next couple hours. We can safely close this, it's on next Backpack version: 6.2.5 |
Feature Request
What's the feature you think Backpack should have?
Backpack just implemented the relationship option for ajax selects and multiple selects. It would be nice to have a property in these select fields along the lines of 'hyperlink => true', which would make the items that are listed out clickable and would allow the user to navigate to that specific model's CRUD Controller to edit / view that item by clicking on it.
Right now our clients ask for this all the time and we end up building out custom templates for this which is a lot of work and renders a large feature of backpack pretty useless for us because of a smaller requirement.
Have you already implemented a prototype solution, for your own project?
No
Do you see this as a core feature or an add-on?
Core Feature
The text was updated successfully, but these errors were encountered: