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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

$url_handlers and forms?


Reply


4 Posts   407 Views

Avatar
Pix

Community Member, 153 Posts

30 August 2014 at 4:49am

I'm having a problem getting my form action to process, my url handlers look like this:

private static $url_handlers = array(
'//$Action/$ID/$OtherID' => 'handleMyRequest'
);

I have a form 'myCustomForm' with the action 'doFormAction'

I'm probably not understanding how routing works, I know that the form is somehow assigned as the $Action on submit, because after submitting the site is redirected to:

http://mysite/mypage/myCustomForm

and the form action is not processed. So in 'handleMyRequest' I tried to call 'doFormAction' but that doesn't seem to do anything with the form data. I hope I am explaining this well, any ideas?

Thank you

Avatar
Pix

Community Member, 153 Posts

30 August 2014 at 10:16am

Man this is a stumper! Someone must have done this? A form on a page with url_handlers? What's the trick? Been at it all day!!!

Avatar
Willr

Forum Moderator, 5513 Posts

30 August 2014 at 10:49pm

In this case you don't need to muck with the $url_handlers. You're correct the form action will go directly back to the Form action (so you must have 'myCustomForm' as an allowed action and not rely on anything else to return the form object). The actual form action is called by Form::httpSubmission() based on what is in the REQUEST data.

If you paste your whole code example I might be able to help a little bit more.

Avatar
Pix

Community Member, 153 Posts

3 September 2014 at 1:42pm

Hi Will,

Thank you for your advice, I was able to get this to work. I did wind up re-writing my handlers as such:

private static $url_handlers = array(
'category/$ID' => 'byCategory',
'tag/$ID' => 'byTag'
);

And I think I was missing 'myCustomForm' as an allowed action, but it is all good now. I really appreciate your response!