Jump to:

2012 Posts in 1438 Topics by 621 members

Form Questions

SilverStripe Forums » Form Questions » Custom form question

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

Page: 1
Go to End
Author Topic: 1300 Views
  • SilverRay
    Community Member
    167 Posts

    Custom form question Link to this post

    OK, simple question. I have this custom form:

       function TestForm() {
          $fields = new FieldSet(
             new TextField('NumA', 'Number A'),
             new TextField('NumB', 'Number B')
          $actions = new FieldSet(
             new FormAction('doSubmitNumbers', 'Calculate')

          $form = new Form(
          return $form;

    The only thing I want the function doSubmitNumbers to do, is to perform some calculation (say, add NumA and NumB) and show the result on the page when it redirects back. I know how I would use doSubmitNumbers to save to the database, but I actually don't want to save to the database, just show the result of the calculation... How would I go forward?


    Edit: wording.

  • Willr
    Forum Moderator
    5511 Posts

    Re: Custom form question Link to this post

    doSubmitNumbers doesn't save anything to the database per se, what its used for is "Run doSubmitNumbers() when you have submitted the form" as to what doSubmitNumbers() does - it could write the DB or it could in your case be used to redirect the user and add numbers

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.