How to have an Action with a url() method, execute code before opening the link?
Hi there,
I have an action object with a url link and I want to update the database when it is clicked. I can't get the database update to work in the action method or in any other method I tried. Is there a way to do this? Alternatively how do I open a link in the action method after updating the database?
5 Replies
Something like that?
Thanks @Homd when I tried this it would log the click when the url is generated for the page and not when it was clicked so it would record a click per page view. Let me test again.
That actually make sense haha.
Maybe just create a custom controller for that? I can't find anything in the docs that lets you do both action and url
Ok, might be the only way.
Trying to figure out how to send a redirect from the action method.
Ok so I can do something like this in the blade template.
is there a way to have this added to the action in the form definition programatically? I.E. I don't need to go and move my actions out of the form to make them blade templates?
Trying to use
but getting what appears to be issues around escaping apostrophes.
Solution
The answer is use HtmlString as suggested by @Leandro Ferreira