Skip to content
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

Provide a way to set a route instead of the absolute link in a select or action column #270

Closed
wants to merge 8 commits into from

Conversation

halfpastfouram
Copy link

Solution for issue #268.

Solution for Action Button

I've used the ZF2 view helper URL inside ZfcDatagrid\Renderer\BootstrapTable\View\Helper\TableRow since that is already a view helper itself. If you've got a router setup this works out of the box.

You can now do the following:

$action->setRoute( 'myRoute' );
$action->setRouteParams( [
    'month' => $column->getColumnValuePlaceholder( 'month' ),
    'id'    => $column->getColumnValuePlaceholder( 'id' ),
] );

Solution for Select Column

Set the router you want to use in the Datagrid:

$datagrid->setRouter( $serviceLocator->get( 'router' ) );

Then set a route on a link formatter and provide that formatter to the column:

$formatter = new \ZfcDatagrid\Column\Formatter\Link();
$formatter->setRoute( 'myroute' );
$formatter->setRouteParams( [
    'month' => $column->getColumnValuePlaceholder( 'month' ),
    'id'    => $column->getColumnValuePlaceholder( 'id' ),
] );
$col1->addFormatter( $formatter );

*/
public function hasRouter()
{
return !is_null($this->translator);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halfpastfouram wrong variable

&& $this->getRouter() instanceof RouteStackInterface
) {
/** @var Column\Formatter\RouterInterface */
$formatter->setRouter($this->getrouter());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@halfpastfouram method lower case

@halfpastfouram
Copy link
Author

All of the builds in travis fail because of "Your requirements could not be resolved to an installable set of packages.". Something is up with the composer requirements, but this does not seem to be caused by my edits.

@ThaDafinser
Copy link
Owner

@halfpastfouram the prefer-lowest parts i failing because of the resolving

In the other there are some php-cs-fixer issues
just run vendor/bin/php-cs-fixer fix and they should turn green

https://travis-ci.org/ThaDafinser/ZfcDatagrid/jobs/201881803#L328

@ThaDafinser
Copy link
Owner

@halfpastfouram after the cs issues are resolved, i'm going to fix the resolve issue.

In general i would say the PR LGTM - a small improvement would be a trait / interface for the get/set/hasRouter part, since it's "copied" several times - but it's not required.

@halfpastfouram
Copy link
Author

@ThaDafinser I agree with you on the trait and interface. Would indeed be an improvement, but haven't had the time to implement that yet. I could improve it a bit in a later stage. Right now I can't wait until this is implemented because it's gonna make my life/job so much easier.

What do you mean exactly by the cs issues? Is there anything you need me to do?

@ThaDafinser
Copy link
Owner

@halfpastfouram i will fix it for you in your PR, since you don't know it (later this day)
https://github.com/FriendsOfPHP/PHP-CS-Fixer

It's just coding style violations

@ThaDafinser ThaDafinser changed the base branch from master to develop February 16, 2017 14:37
@ThaDafinser
Copy link
Owner

merged to develop branch see #272

Thank you! 👍
(your contributions will stay intact over your commits)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants