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.


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

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

how to put my own form (formular) on webpage


6 Posts   2962 Views


13 March 2008 at 1:37pm Community Member, 9 Posts

I'd like to put in the source of the content page my own form for example:
<form action="my_script.php" method="post" name="name" id="name">
<input type="company_name" name="textfield">

This form will run my_script.php. The script should process variables sended by post (in this example company_name variable), then give some results (from my own databases) and put it back one the webpage.

How to do it, cause now I have SS parsing error (cant parse form tag):


13 March 2008 at 8:53pm Forum Moderator, 5511 Posts

you might want to read up on SilverStripe forms - The second part of that - the browser poll you should be able to use/adapt that.


14 March 2008 at 1:48am Community Member, 9 Posts

thanks for support. I've read it.

But the problem is, how to run my own script which will access my own database (from my other application) and give back results on silverstripe page.

could You help me with short instruction.


14 March 2008 at 9:26am Forum Moderator, 5511 Posts

right so using the the tutorial code as a template.. theres 2 PHP functions 1- BrowserPollForm() this is the function to output the form so this will be where you add your text fields and submit buttons etc... The second function doBrowserPoll() is much more interesting. This method is what is called when people submit the form.

So I don't know what your my_script.php file does but if you copy the code from that into the doBrowserPoll() function (replacing variables etc etc) and use that method to connect to your database and process the form / do whatever you want.

If you post some code someone might be able to look into it for you.


9 April 2008 at 2:39pm Community Member, 54 Posts

I'm also curious about this.. I need to submit a form to an external site for processing. I cannot get the code from the remote location as it's a third party processor.

So in short I would love the ability to customise the action tag of the <form> tag. I realise that this may be accomplished with javascript on the user end, but this does not work for two reasons:

1) The odd chance that the user does not have js enabled.
2) That I already have a script rewriting the action tag (also third party js!)

Thanks for any help!


9 April 2008 at 4:34pm Community Member, 54 Posts

Thanks to simon_w in the SS chat room i've fixed my problem.

Simply sub class the Form class like so and replace the FormAction function with what you want in the action attribute:

class extForm extends Form {
   function init() {
   function FormAction() {
      return '';

Then reference the new form like so

return new extForm($this, 'extContactForm', $fields, $actions, $validator);

Thanks simon!