atk4 / ui

Robust and easy to use PHP Framework for Web Apps
https://atk4-ui.readthedocs.io
MIT License
440 stars 105 forks source link

Adding simple redirect action button in CRUD is hard #140

Open DarkSide666 opened 7 years ago

DarkSide666 commented 7 years ago

If we want to add button column in CRUD which will simply navigate away to another page and pass rows ID, then it's not that trivial to do. Also need to add custom JavaScript.

Currently we can do that like this:

$c->addAction(
    new \atk4\ui\Icon('money'),
    new \atk4\ui\jsExpression(
        'document.location="money.php?friend_id="+$(this).closest("tr").data("id");'
    )
);
romaninsh commented 7 years ago

See pr #156, with that you could do:

$c->addAction(['icon'=>'money'], function($js, $id) { return .... });

Also per style you should use Link if user is taken to another page.

DarkSide666 commented 5 years ago

Do we have example of this in docs? If yes then I think this issue can be closed. If no, then maybe we should add example in docs.

TheNetworkIsDown commented 4 years ago

Is there a simple solution for this in the meantime? ATK is cool for some reason. However I'm always getting stuck with the simplest of things after a few minutes. Sorry for "venting" here but it's not really user- and especially not beginner-friendly if you're stuck all the time and the best examples you find (even if it doesn't do what you like) are the unit tests in the code :( That probably scares a lot of people away, otherwise this would rock.

DarkSide666 commented 4 years ago

However I'm always getting stuck with the simplest of things after a few minutes.

I suffered with this also years ago when I was starting to dive in Agile Toolkit libraries :) Nowadays i think it's much better, but still such cases can happen and should be addressed.

mvorisek commented 1 year ago

@DarkSide666 what is currently the best option and how can this be improved?

mvorisek commented 1 year ago

Money class - https://github.com/atk4/ui/blob/5d1bf4c4/src/Table/Column/Money.php should allow currency field to be specified like in CountryFlag class - https://github.com/atk4/ui/blob/5d1bf4c4/src/Table/Column/CountryFlag.php