Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Form Questions /

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

(solved) Show data after submitting a form


Go to End
Reply


4 Posts   1350 Views

Avatar
Beppo98

Community Member, 19 Posts

17 March 2011 at 12:32am

Edited: 17/03/2011 12:32am

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

Avatar
Beppo98

Community Member, 19 Posts

23 March 2011 at 5:19am

Edited: 23/03/2011 5:19am

No ideas how I can solve my problem?

Best regards, Beppo

Avatar
Devlin

Community Member, 237 Posts

23 March 2011 at 6:00am

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.

Avatar
Beppo98

Community Member, 19 Posts

29 March 2011 at 7:40am

Thank you very much, now it works :)

Best regards, Beppo