ui
ui copied to clipboard
Adding simple redirect action button in CRUD is hard
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");'
)
);
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.
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.
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.
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.
@DarkSide666 what is currently the best option and how can this be improved?
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