Jump to:

2011 Posts in 1436 Topics by 620 members

Form Questions

SilverStripe Forums » Form Questions » (solved) Show data after submitting a form

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

Page: 1
Go to End
Author Topic: 1127 Views
  • Beppo98
    Avatar
    Community Member
    19 Posts

    (solved) Show data after submitting a form Link to this post

    Hello,

    I think I have an easy problem. My current form looks like this:

    Depending on the chosen Dropdown item I want to show the user different data. My code looks like this:

    public $SkriptanmeldungenAll;

    function doSubmitDruckliste($data, $form) {
    //some code
    $this->SkriptanmeldungenAll = DataObject::get("Skriptanmeldung","SkriptID = '$SkriptID'");
    //...
    }

    function GetSkriptanmeldungen()
    {
    return $this->SkriptanmeldungenAll;
    }

    An the template looks like this:

    ...
    <% control GetSkriptanmeldungen %>
    <tr style='height:30px' >
    <td>$Nachname</td>
    <td>$Vorname</td>
    <td></td>   
    </tr>
    <% end_control %>

    But if I try to use the button "Anzeigen" no data were shown, because the variable $this->SkriptanmeldungenAll is empty.
    What can I do to display the data?

    I also tried this way:

    function GetSkriptanmeldungen()
    {
    if($_POST['SkriptID'])
    { // return the data }
    }


    But I think the $_POST - Variable isn't be setted.

    Can anyone help me?

    Best regards, Beppo

  • Beppo98
    Avatar
    Community Member
    19 Posts

    Re: (solved) Show data after submitting a form Link to this post

    No ideas how I can solve my problem?

    Best regards, Beppo

  • Devlin
    Avatar
    Community Member
    215 Posts

    Re: (solved) Show data after submitting a form Link to this post

    When you are sure the form data is valid, you can save the ID in a session.

    Session::set('SkriptID',(int)$data['SkriptID']);
    Session::get('SkriptID');

    If you're looking for a cookieless option, you can also use GET parameters via controller.
    http://doc.silverstripe.org/sapphire/en/topics/controller

    Or if a login to your service is required, you can also save the ScriptID & Member::currentUserID() in a DataObject.

  • Beppo98
    Avatar
    Community Member
    19 Posts

    Re: (solved) Show data after submitting a form Link to this post

    Thank you very much, now it works

    Best regards, Beppo

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