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.

All other Modules /

Discuss all other Modules here.

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

[Userform] Change the action to an External URL


Go to End


6 Posts   2170 Views

Avatar
LunakO2

Community Member, 4 Posts

12 December 2010 at 2:06am

Hello All,

Is it possible to take the action URL as an input from the user so that the form can be submitted to external sites (example: Wufoo)

Which PHP Classes/Files would I be required to modify to support this functionality?

Thanks in Advance.

- Kunal Shetye

Avatar
Willr

Forum Moderator, 5523 Posts

12 December 2010 at 10:06am

I think changing the URL is going to be tricky as UDF uses the built in Form classes in SilverStripe. I'm pretty sure you cannot change the action to be external for built in forms. If you wanted to then the way I would imagine you could do it is to alter the Form objects html using an extension to UserDefinedForm. You can customize the form by defining a function updateForm(&$form) in your extension but still not 100% sure how you would get access to the FormAction.

Perhaps using UserForms isn't the best idea.

Avatar
LunakO2

Community Member, 4 Posts

12 December 2010 at 4:45pm

Willr,

There is no way for me to add <form> / <input> elements in the Content Field of a Page, otherwise I would have to resort to Userforms :(

Is there anything else that I could use so that I can use a custom form that posts to an external URL?

Thanks! :)

Avatar
Willr

Forum Moderator, 5523 Posts

13 December 2010 at 3:57pm

Is there anything else that I could use so that I can use a custom form that posts to an external URL?

If the form is static (aka they don't need to change it in the CMS) then simply make your own shortcode handler. You can then make a template file that has the form html you require it in and you bypass the SilverStripe form functionality entirely.

http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/
http://doc.silverstripe.org/shortcodes

Avatar
LunakO2

Community Member, 4 Posts

13 December 2010 at 7:24pm

Willr,

The forms are going to be dynamic in nature, in fact the whole purpose of using Silverstripe in the first place to have the flexibility of editing forms effortlessly, plus other features and benefits.

Avatar
Willr

Forum Moderator, 5523 Posts

14 December 2010 at 6:20pm

Ah ok then I guess your best option is to subclass the UserDefinedForm class (and its controller) and replace the UserDefinedForm_Controller process() function to post to your Wufoo URL. You would probably also need to tweak the process function to make the submitted data make the Wufoo fields since UDF will have form fields with names such as 'EditableTextField12' which Wufoo would not know how to handle.