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.

Archive

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

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

Make forms 'Ajaxy'


Reply

3 Posts   1512 Views

Avatar
dio5

29 September 2007 at 10:37am Community Member, 501 Posts

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: [url]http://www.silverstripe.com/silverstripe-development/flat/5780?showPost=6157#post6157[/url]

Thanks!

Avatar
Ingo

29 September 2007 at 1:43pm Forum Moderator, 801 Posts

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

29 September 2007 at 8:45pm Community Member, 501 Posts

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.