1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 670 Views |
-
(solved) Get Name from selected DropDownList element

15 March 2011 at 5:38am Last edited: 15 March 2011 5:40am
Hello,
I have another question which is - i think so - a very easy question.
Here is my code for creating a form:
function Form() {
$SkripteAll = SkriptHelper::GetSkripte()->toDropdownMap('ID', 'Name');
$fields = new FieldSet(
new DropdownField('Skript','', $SkripteAll)
);$actions = new FieldSet(
new FormAction('doSubmit', 'Anzeigen')
);$form = new Form(
$this,
'Form',
$fields,
$actions,
null
);
return $form;
}Now I want to know in the doSubmit method, which item the user has selected.
With$data['Skript']
in the doSubmit method I get the ID (for example 1). But I want to know the name or much better I want to know the complete Skript-object, which I have mapped from the database into the dropdownfield.Can anyone help me with my problem?
Best regards Beppo
-
Re: (solved) Get Name from selected DropDownList element

15 March 2011 at 6:08am
public $SkripteAll;
function Form() {
$this->SkripteAll = SkriptHelper::GetSkripte()->toDropdownMap('ID', 'Name');
}
function doSubmit($data,$form) {
$SkriptID = (int)$data['Skript'];
if( !empty($this->SkripteAll[$SkriptID]) ) $selectedSkript = $this->SkripteAll[$SkriptID];
} -
Re: (solved) Get Name from selected DropDownList element

15 March 2011 at 8:10am
Thanks for your answer, now it works.
But I have another problem you perhaps could help me. Currently I have one dropdownfield and a button in my form. Depending on the chosen element in the dropdownfield I want to display different data in the frontend page.
At the moment I tried it to solve in this way:
public $SkriptanmeldungenAll;
function doSubmitDruckliste($data, $form) {
//some code
$this->SkriptanmeldungenAll = DataObject::get("Skriptanmeldung","SkriptID = '$SkriptID'");
//...
}function GetSkriptanmeldungen($SkriptID)
{
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 at the momentan no data are displayed.
Best regards, Beppo
-
Re: (solved) Get Name from selected DropDownList element

17 March 2011 at 12:34am Last edited: 17 March 2011 12:34am
| 670 Views | ||
|
Page:
1
|
Go to Top |


