Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Make forms 'Ajaxy'


Go to End


3 Posts   1972 Views

Avatar
dio5

Community Member, 501 Posts

29 September 2007 at 10:37am

I'm going to want some forms of mine enhanced with ajax.

Now I know how to do this the normal way, but haven't got a single clue on how to do it in SS. Where should I send my request to? To the controller.php? Or do I make a complete new controller for it?

I also came across 'FormResponse' and 'AjaxActionForm' but the documentation didn't make me a lot wiser... Is there anybody here with some experience / or some examples?

And if you know the answer, please take a look at what I'm doing wrong here: http://www.silverstripe.com/silverstripe-development/flat/5780?showPost=6157#post6157

Thanks!

Avatar
Ingo

Forum Moderator, 801 Posts

29 September 2007 at 1:43pm

Hm, just use the normal form action thats generated by the form, submitted by an ajax-call instead of a normal POST-request (e.g. by prototype's Ajax.Request-object).

AjaxFormAction isn't really needed for this, afaik its mostly specific to the backend where all "normal" actions in a form are processed a bit differently to build the "button-bar" you see in the interface.

FormResponse is a nice wrapper that lets you create responses for ajax/non-ajax calls (e.g. returning json vs. a full html-page). it determines automatically the format you need, and has some other useful functions like refreshing a cms-form with reapplying javascript-behaviour.

http://doc.silverstripe.com/doku.php?id=formresponse

Avatar
dio5

Community Member, 501 Posts

29 September 2007 at 8:45pm

Mm, I'll give it a try the 'normal way'. Don't run too far as I'll probably be coming back on this one :-)

I looked into formResponse but it didn't make me a lot wiser... and when I clicked the documentation-link I was presented with an login - box.