Hello Community,
I searched for an answere, but what I found, didn't solve my problem.
The problem is, that I have a form, but the responding action is not called, the page is just refreshed.
Here is my code:
class InsertPage_Controller extends Page_Controller
{
private static $allowed_actions = array('doInsertCall', 'insertCall');
public function insertCall($data = null, $form = null)
{
$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:', $this->getAgents())
, new TextField('topic', 'Thema:')
);
$actions = new FieldList(
new FormAction('doInsertCall', 'Eintragen')
);
return new Form($this, 'insertCall', $fields, $actions);
}
public function doInsertCall($data, $form)
{
$sub = new insertCallSubmission();
$form->saveInto($sub);
$sub->write();
return $this->redirectBack();
}
}
I have to put this code in the insertCall function to write the data to the DB:
public function insertCall($data = null, $form = null)
{
if ($data)
{
$x = $data->postVars();
$submission = new insertCallSubmission();
$submission->telefone = $x['telefone'];
$submission->name = $x['name'];
$submission->subject = $x['subject'];
$submission->note = $x['note'];
$submission->date = $x['date'];
$submission->time = $x['time'];
$submission->agent = $x['agent'];
$submission->topic = $x['topic'];
$submission->write();
}
$fields = new FieldList(
...
Does anybody know where the problem is?