خرید بک لینک

Vote count: 0

if I click at the submit button to send data from my silverstripe form to the database (xampp, mysql), it doesn't redirect me back to the form page. Instead it redirects to "{BaseUrl}name_of_controller/name_of_form" -> in my case: "localhost/pmtool/DeveloperController/NewTaskMask". I have searched for hours for the solution of this problem, but without any success.

Here's the code of the file, in which the form and the action is defined. In an other html-file the form will be called through $NewTaskMask. By the URL "localhost/pmtool/developer/newtask" the function "renderNewTaskForm" will be called, the template with $NewTaskMask will be rendered. All fields such as Title, Description, ... do exist in the database.

<?php

class DeveloperController extends ContentController {

private static $allowed_actions = array('NewTaskMask','renderNewTaskForm');

private static $url_handlers = array(
    'newtask' => 'renderNewTaskForm'
);

public function renderNewTaskForm(SS_HTTPRequest $request) {
    retu $this->renderWith('NewTaskForm');
}

public function NewTaskMask() {
    $fields = new FieldList(
        TextField::create('Title','Title')
            ->setAttribute('autocomplete', 'off')
            ->setAttribute('placeholder', 'Enter a task title ...'),
        TextareaField::create('Description','Description')
            ->setAttribute('autocomplete', 'off'),
        DropdownField::create('Project','Project', Project::get()->map('ID','Title')),
        DropdownField::create('Developer','Developer', Developer::get()->map('ID','Title'))
    );

    $actions = new FieldList(FormAction::create('doCreateT','Task anlegen'));

    $requiredFields = new RequiredFields(array('Title'));

    retu new Form($this, 'NewTaskMask', $fields, $actions, $requiredFields);
}

public function doCreateT($data, $form) {

    // Creating a new task record
    $nT = new Task();

    $nT->Title = $data['Title'];
    $nT->Description = $data['Description'];
    $nT->Project = $data['ProjectID'];
    $nT->Developer = $data['DeveloperID'];
    $nT->write();

    // Create a nice msg for our users
    $form->sessionMessage('Task angelegt!','good');

    // Redirect back to the form page
    retu $this->redirectBack();
}

}

PLS help a frustrated student! :)

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 5 مرداد 1395 ساعت: 10:45

صفحه بندی