This project is read-only.

Make a button post data on General Settings page

Topics: Writing modules
Oct 9, 2011 at 8:10 PM
Edited Oct 9, 2011 at 9:33 PM

Hi all!

I'd like to have a button on the General Settings page that should trigger a post to a controller action. In other words, the button should post a custom data to another page. How would you do that properly? The button is part of a SiteSettings part, laid out from a driver.

If I make the button a submit one, it will submit the whole settings form, but this would be wrong. The button also could have some javascript, but using JS to post data seems just wrong (as it wouldn't be unobtrusive JS). The button could be also just a simple link, invoking the action with a GET, but as the action would alter the state of the application, this would be incorrect in the sense of HTTP. What would you advise? I haven't seen any examples of such functionality.

Oct 10, 2011 at 9:19 PM

There are actually other places in the admin where we do that, and the simplest is to do it with JavaScript. It does have the disadvantages you cite but as there already is a surrounding form and html doesn't play well with nested forms, it may be your cleanest option. The option of sending the whole form would work, but you would still need javascript to change the action for the form, sooo....

Oct 16, 2011 at 1:18 PM

Thanks, I actually have done it with JS (by making an AJAX call).