Jump to:

1971 Posts in 1275 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » receiving parameters in a form?

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

Page: 1
Go to End
Author Topic: 379 Views
  • _Vince
    Avatar
    Community Member
    156 Posts

    receiving parameters in a form? Link to this post

    Hi, I have a form that I am calling from a 2.4 page.

    I have a function that calls the form

          $val1= new TextField("val1", "val1", "1");
          $val2 = new TextField("val2", "val2", "2");
          $val3 =new TextField("val3", "val3", 3);
          
          $params = new FieldSet($val1, $val2 , $val3 );

        if(Member::currentUser()){
             return new frmAnswerQuestion($this, 'answerQuestion', $params);
          }
          else{
             return "<p>Sorry, you're not a member</p>";
          }

    and then the form receives the params

    class frmAnswerQuestion extends Form{

    /***********************************************************************/
       function __construct($controller, $FormName, $fields) {
    /***********************************************************************/

    Debug::show($fields);
    Debug::show("val1: " . $fields->val1);

    And the first Debug::show() works fine and shows that there are values being received. Correctly.

    But if I try to access the actual contents, as in the 2nd debug, I just get a null value.

    How do I access the value of val1?

    379 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.