Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » getting form data from 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: 1102 Views
  • lozhowlett
    Avatar
    Community Member
    146 Posts

    getting form data from a form Link to this post

    Hi everyone

    I cant seem to find the simple to answer to getting the actual form data submitted... I think this will show what I am trying to do...

    function results($data, $form){

    //echo $form;

    Session::set('minprice', $data->$minprice);
    Session::set('maxprice', $data->$minprice);
    Session::set('minbeds', $data->$minprice);
    Director::redirect("properties/");
    }

    basically i want to put into the session var the value of the form field submitted.... I cant find documentation on this anywhere!!

    In asp i would do something like

    MyVar = request.form("FieldName")

    Any help would be great!

    Thanks

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: getting form data from a form Link to this post

    firstly try

    Debug::show($data);

    to understand what is in the var, then maybe

    $vars = $data->postVars();

    will provide you data int eh expected $_POST format

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: getting form data from a form Link to this post

    thanks for that... however i get

    Fatal error: Call to a member function postVars() on a non-object in /var/sites/t/test.jplettings.com/public_html/mysite/code/Page.php on line 61

    Any ideas?

    //Debug::show($data);
    $vars = $data->postVars();
    Debug::show($vars);
    Session::set('minprice', $data->$minprice);
    Session::set('maxprice', $data->$minprice);
    Session::set('minbeds', $data->$minprice);
    Director::redirect("properties/");

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: getting form data from a form Link to this post

    ok, what about the first debug show, doesn't that let you know the class name and data?

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: getting form data from a form Link to this post

    This is the data I get...

    Debug (Page_Controller->results() in line 60 of Page.php)

    url =
    /property-holder/54-new-street/SearchForm
    minprice =
    0
    maxprice =
    0
    minbeds =
    1
    action_results =

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: getting form data from a form Link to this post

    so have you tried $data['minprice']?

  • lozhowlett
    Avatar
    Community Member
    146 Posts

    Re: getting form data from a form Link to this post

    no - thats what I needed to know! Thank you is that standard PHP or SS specific? I am on a big learning curve! cheers

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