Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

764 Posts in 245 Topics by 252 members

Form Questions

SilverStripe Forums » Form Questions » Custom form question

Page: 1
Go to End
Author Topic: Custom form question 474 Views
  • SilverRay
    avatar
    Community Member
    158 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
    Moderator
    2744 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

    474 Views
Page: 1
Go to Top

Currently Online: Euphemismus, Sean

Welcome to our latest member: fearofbuttons

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

Comments on this website? Please give feedback.