Jump to:

1969 Posts in 1272 Topics by 606 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: 1244 Views
  • SilverRay
    Avatar
    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(
             $this,
             'Form',
             $fields,
             $actions
          );
          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?

    Thanks!

    Edit: wording.

  • Willr
    Avatar
    Forum Moderator
    5462 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

    1244 Views
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.