hey guys, i need help :D
when i create any form to many any stuff, i do this for example:
function SpeicherSprache() {
if(Member::currentUserID()) {
$fieldset = new FieldSet(
new TextField(
$name = "Sprache",
$title = "Sprache",
$value = ""
...
...
...
...
new TextField(
$name = "Muttersprache",
$title = "Muttersprache",
$value = ""
)
);
$actions = new FieldSet(
new FormAction('doSenden', 'Submit')
);
return new Form($this, 'SpeicherSprache', $fieldset, $actions);
} else
return false;
}
function doSenden($data, $form) {
$submission = new SprachenObjekt();
$form->saveInto($submission);
$submission->write();
Director::redirectBack();
}
and this works. "SprachenObjekt" is just a DataObjekt i created.
soo.. now the User should have an DropdownField to choose one ob the many "SprachenObjekt" in the DB.
hier code:
function HoleSprache() {
$myDoSet = DataObject::get("SprachenObjekt","");
if($myDoSet){
$map = $myDoSet->toDropDownMap('ID', 'Sprache');
$map = str_replace($search = array('<', '>'), $replace = array('<', '>'), $map);
$fieldset = new FieldSet(
new DropdownField(
$name = "sprachen",
$title = "Sprache wählen",
$source = $map,
$value = ""
)
);
}
$actions = new FieldSet(
new FormAction('ZeigeSprache', 'Anzeigen')
);
return new Form($this, 'HoleSprache', $fieldset, $actions);
}
function ZeigeSprache() {
if(!isset($_POST['sprachen']))
$_POST['sprachen'] = 1;
$sprache = new DataObjectSet();
$result = DB::query("SELECT * FROM SprachenObjekt WHERE ID = '".$_POST['sprachen']."'");
if($result) {
foreach($result as $value) {
$eintraege = array(
'ID' => $value['ID'],
'Sprache' => $value['Sprache'],
'Kaum' => $value['Kaum'],
'Mittel' => $value['Mittel'],
'Gut' => $value['Gut'],
'Muttersprache' => $value['Muttersprache']
);
$sprache->push(new ArrayData($eintraege));
}
}
return $sprache;
}
And this code is in my .SS file:
$HoleSprache
<% control ZeigeSprache %>
$Sprache<br />
$Kaum<br />
$Mittel<br />
$Gut<br />
$Muttersprache<br />
<% end_control %>
Now when i enter into this page, the Data of DB entry with "ID = 1" is shown.
And there is the DropdownField and the Button.. BUT when i click the button i just get a white page with the word "DataObjektSet".
Okay, in other forms, there is a "RedirectBack()" in the called function.. so i dont know how to handle this problem.. :S
THANKS FOR ANSWERS