Hallo,
I am new to SilverStripe, and try to code a simple ``callcenter'' page, where calls can be stored and viewed.
The Version of SilverStripe is 3.1.8., and I worked through the tutorials.
To save formdata into the db is handled in tutorial #3, and I thought, I did everything like it is said there,
but the when I submit the data, i just get an empty form as a result, and nothing is written to the db.
Here is my code:
InsertPage.php
<?php
class InsertPage extends Page
{
}
class InsertPage_Controller extends Page_Controller
{
private static $allowed_actions = array('insertCall');
public function insertCall()
{
$fields = new FieldList(
new TextField('telefone', 'Telefonnummer')
, new TextField('name', 'Name')
, new TextareaField('subject', 'Betreff')
, new TextareaField('note', 'Anmerkung')
, new TextField('date', 'Datum', date('d.m.Y', time()))
, new TextField('time', 'Uhrzeit', date('H:m', time()))
, new HiddenField('createDate')
, new HiddenField('createUser')
, new HiddenField('assignedAgent')
, new HiddenField('isProcessed')
, new DropdownField('agent', 'Verantwortlicher', array('heinz' => 'Heinz', 'uwe' => 'Uwe', 'karl' => 'Karl', 'henrette' => 'Henriette', 'walter' => 'Walter', 'eva' => 'Eva'))
, new DropdownField('topic', 'Thema', array('order' => 'Bestellung', 'info' => 'Information', 'offer' => 'Angebot', 'private' => 'Privat'))
);
$actions = new FieldList(
new FormAction('doInsertCall', 'Eintragen')
);
return new Form($this, 'insertCall', $fields, $actions);
}
public function doInsertCall($data, $form)
{
$submission = new insertCallSubmission();
$submission->write();
$form->saveInto($submission);
$submission->write();
return $this->redirectBack();
}
}
?>
insertCallSubmission.php:
<?php
class insertCallSubmission extends DataObject
{
private static $db = array(
'telefone' => 'Varchar'
,'name' => 'Varchar'
,'subject' => 'Text'
,'note' => 'Text'
,'date' => 'Date'
,'time' => 'Time'
,'createDate' => 'SS_Datetime'
,'createUser' => 'Varchar'
,'assignedAgent' => 'Varchar'
,'isProcessed' => 'Varchar'
,'agent' => 'Varchar'
,'topic' => 'Varchar'
);
}
?>
What am I missing?
Thanks in advance for your help.