1779 Posts in 582 Topics by 556 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1692 Views |
-
Custom Form redirects to a blank site

6 April 2009 at 5:14pm
Hi.
I created a form to update some data in a database. The first view of the site is fine but if I send the form via the automaticly generated button it will redirect me to a blank page. I looked into the source code of this blank page - it was empty, even no head tags or something like that- nothing.Can anyone explain me this behavior?
I checked my sourcecode more than one time and didnt find a mistake but ... well maybe I´m overlooking something.The whole thing is done by a subclass of Page and its Controller.
Here is a snippet of my Code, I also attached the whole file./**
* Das Formular für die Seite
* Hier kann der Datensatz leicht manipuliert werden.
*/
function Form(){$auftrag = $this->getAuftrag();
if($auftrag){
// Daten für die Dropdownliste Kunde holen
$kunden = DataObject::get('Kunde');
if ($kunden){
$kundenSources = $kunden->toDropDownMap('ID', 'Name'); // Datenaufbereite
}$fields = new FieldSet(
new TextField('Auftragsnummer', 'Auftragsnummer', $auftrag->Auftragsnummer),
new TextField('Thema', 'Thema', $auftrag->Thema),
new DateField('Startdatum', 'Startdatum', $this->DatumsWandler($auftrag->Startdatum)),
new DateField('Enddatum', 'Enddatum', $this->DatumsWandler($auftrag->Enddatum)),
new CheckboxField('Abgeschlossen', 'Abgeschlossen', $auftrag->Abgeschlossen),
new DropdownField('KundeID', 'Kunde', $kundenSources, $value=$auftrag->KundeID)
);$actions = new FieldSet(
new FormAction('doAuftragUpdate', 'Auftrag aktualisieren')
);;
$validator = new RequiredFields(
'Auftragsnummer',
'Thema',
'Startdatum',
'Enddatum'
);$form = new Form(
$this,
'Form',
$fields,
$actions,
$validator
);return $form;
}
}function doAuftragUpdate($data, $form){
$auftrag = $this->getAuftrag();
if($auftrag){
$form->saveInto($auftrag);
$auftrag->write();
$form->sessionMessage('Der Auftrag wurde erfolgreich aktualisiert', 'good');
}
Director::redirectBack();
return;}
-
Re: Custom Form redirects to a blank site

7 April 2009 at 9:25pm
Hey there,
That would indicate that Director::redirectBack() is not working. Are you sure it is getting that far? Have you turned on dev-mode? What if you try Director::redirect('some-random-url')?
-
Re: Custom Form redirects to a blank site

9 April 2009 at 2:53am
Its working.
I just add a else-conidtion in the funtion form()
Where I return a blank form
| 1692 Views | ||
|
Page:
1
|
Go to Top |


