Jump to:

23493 Posts in 19013 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Dynamically replace a form

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

Page: 1
Go to End
Author Topic: 332 Views
  • Xazen
    Community Member
    18 Posts

    Dynamically replace a form Link to this post

    Hi SilverStripe Community,

    I want to create a contact page which can display different forms. On the right are <button/>-TAGs to switch between the forms.

    For example my contact.ss looks like this and my page type has got the functions $FormOne and $FormTwo to return a form:

    <div id="Form">

    After I click on the 2nd button $FormOne should be replaced by $FormTwo.

  • martimiz
    Forum Moderator
    1086 Posts

    Re: Dynamically replace a form Link to this post

    Looking at the options that I can think of:

    1. have multiple forms on the page, and show the required one using JavaScript. Considerable overhead, not easy to implement the correct response to the form, spamprotection and stuff, so I wouldn't

    2. if the button is pressed, reload the page with the desired form (?form=myform or implement a action/rule?)

    3. use AJAX to dynamically load the desired form into some container. Maybe falling back to (2) when no javascript available.

    Oh... and the simplest: just have separate pages, each with their own form, replace the custom buttons by a submenu...

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.