I need to pass some data from form to database in SilverStripe, but when I click on "Send" button, all I got is a reload of form with blank fields, and of course no data in db. Here's the code of the form file (it's too long to be pasted into code tags here): http://pastebin.com/KHnZug9Z
and that's how the DataObject file looks like:
/**
* Class MonthlyReviewRequest
*/
class MonthlyReviewRequest extends DataObject {
protected $controller;
protected $record;
private static $db = array(
'NameAndSpecialisation' => 'Varchar(255)',
'MBRDate' => 'Date',
'PredictionCompaniesAdded' => 'Int',
'PredictionManagersAdded' => 'Int',
'PredictionCandidatesAdded' => 'Int',
'PredictionSendoutsDone' => 'Int',
'PredictionLivejobsPerm_Con' => 'Int',
'PredictionMailshotsDone' => 'Int',
'Prediction1stInterview' => 'Int',
'Prediction2ndInterview' => 'Int',
'PredictionAddsAdded' => 'Int',
'PredictionMeetingsAdded' => 'Int',
'PredictionProjectPlanSendSigned' => 'Int',
'PredictionRetainer1' => 'Text',
'PredictionRetainer2' => 'Text',
'PredictionDealsAddedPermCon' => 'Int',
'ActualCompaniesAdded' => 'Int',
'ActualManagersAdded' => 'Int',
'ActualCandidatesAdded' => 'Int',
'ActualSendoutsDone' => 'Int',
'ActualLivejobsPerm_Con' => 'Int',
'ActualMailshotsDone' => 'Int',
'Actual1stInterview' => 'Int',
'Actual2ndInterview' => 'Int',
'ActualAddsAdded' => 'Int',
'ActualMeetingsAdded' => 'Int',
'ActualProjectPlanSendSigned' => 'Int',
'ActualRetainer1' => 'Text',
'ActualRetainer2' => 'Text',
'ActualDealsAddedPermCon' => 'Int',
'PipelinePermJob' => 'Text',
'PipelinePerm1stInt' => 'Int',
'PipelinePermStatus' => 'Text',
'PipelineConJob' => 'Text',
'PipelineCon1stInt' => 'Int',
'PipelineConStatus' => 'Text',
'ActionPlan' => 'Text',
'PromotionTarget' => 'Float',
'Leadership' => 'Text',
'DevelopmentPoints' => 'Text',
'TrainingAndHelp' => 'Text',
'OtherPoints' => 'Text'
);
private static $has_one = array(
'Page' => 'Page'
);
/**
* @param bool $includerelations
* @return array|string
*/
public function fieldLabels($includerelations = true) {
$labels = parent::fieldLabels();
$labels['NameAndSpecialisation'] = _t('MonthlyReviewRequest.NameAndSpecialisation', "Name and specialisation:");
$labels['MBRDate'] = _t('MonthlyReviewRequest.MBRDate', "MBR Date:");
$labels['PredictionCompaniesAdded'] = _t('MonthlyReviewRequest.PredictionCompaniesAdded', "Companies added:");
$labels['PredictionManagersAdded'] = _t('MonthlyReviewRequest.PredictionManagersAdded', "Managers added:");
$labels['PredictionCandidatesAdded'] = _t('MonthlyReviewRequest.PredictionCandidatesAdded', "Candidates added:");
$labels['PredictionSendoutsDone'] = _t('MonthlyReviewRequest.PredictionSendoutsDone', "Sendouts done:");
$labels['PredictionLivejobsPerm_Con'] = _t('MonthlyReviewRequest.PredictionLivejobsPerm_Con', "Livejobs Perm/Con:");
$labels['PredictionMailshotsDone'] = _t('MonthlyReviewRequest.PredictionMailshotsDone', "Mailshots done:");
$labels['Prediction1stInterview'] = _t('MonthlyReviewRequest.Prediction1stInterview', "1st Interview:");
$labels['Prediction2ndInterview'] = _t('MonthlyReviewRequest.Prediction2ndInterview', "2nd Interview:");
$labels['PredictionAddsAdded'] = _t('MonthlyReviewRequest.PredictionAddsAdded', "Adds added:");
$labels['PredictionMeetingsAdded'] = _t('MonthlyReviewRequest.PredictionMeetingsAdded', "Meetings added:");
$labels['PredictionProjectPlanSendSigned'] = _t('MonthlyReviewRequest.PredictionProjectPlanSendSigned', "Project plans send / signed:");
$labels['PredictionRetainer1'] = _t('MonthlyReviewRequest.PredictionRetainer1', "Retainer 1:");
$labels['PredictionRetainer2'] = _t('MonthlyReviewRequest.PredictionRetainer2', "Retainer 2:");
$labels['PredictionDealsAddedPermCon'] = _t('MonthlyReviewRequest.PredictionDealsAddedPermCon', "Deals added Perm / Con:");
$labels['ActualCompaniesAdded'] = _t('MonthlyReviewRequest.ActualCompaniesAdded', "Companies added:");
$labels['ActualManagersAdded'] = _t('MonthlyReviewRequest.ActualManagersAdded', "Managers added:");
$labels['ActualCandidatesAdded'] = _t('MonthlyReviewRequest.ActualCandidatesAdded', "Candidates added:");
$labels['ActualSendoutsDone'] = _t('MonthlyReviewRequest.ActualSendoutsDone', "Sendouts done:");
$labels['ActualLivejobsPerm_Con'] = _t('MonthlyReviewRequest.ActualLivejobsPerm_Con', "Livejobs Perm/Con:");
$labels['ActualMailshotsDone'] = _t('MonthlyReviewRequest.ActualMilshotsDone', "Mailshots done:");
$labels['Actual1stInterview'] = _t('MonthlyReviewRequest.Actual1stInterview', "1st Interview:");
$labels['Actual2ndInterview'] = _t('MonthlyReviewRequest.Actual2ndInterview', "2nd Interview:");
$labels['ActualAddsAdded'] = _t('MonthlyReviewRequest.ActualAddsAdded', "Adds added:");
$labels['ActualMeetingsAdded'] = _t('MonthlyReviewRequest.ActualMeetingsAdded', "Meetings added:");
$labels['ActualProjectPlanSendSigned'] = _t('MonthlyReviewRequest.ActualProjectPlanSendSigned', "Project plans send / signed:");
$labels['ActualRetainer1'] = _t('MonthlyReviewRequest.ActualRetainer1', "Retainer 1:");
$labels['ActualRetainer2'] = _t('MonthlyReviewRequest.ActualRetainer2', "Retainer 2:");
$labels['ActualDealsAddedPermCon'] = _t('MonthlyReviewRequest.ActualDealsAddedPermCon', "Deals added Perm / Con:");
$labels['PipelinePermJob'] = _t('MonthlyReviewRequest.PipelinePermJob', "Job");
$labels['PipelinePerm1stInt'] = _t('MonthlyReviewRequest.PipelinePerm1stInt', "No. of 1st Int");
$labels['PipelinePermStatus'] = _t('MonthlyReviewRequest.PipelinePermStatus', "Status");
$labels['PipelineConJob'] = _t('MonthlyReviewRequest.PipelineConJob', "Job");
$labels['PipelineCon1stIn'] = _t('MonthlyReviewRequest.PipelineCon1stIn', "No. of 1st Int");
$labels['PipelineConStatus'] = _t('MonthlyReviewRequest.PipelineConStatus', "Status");
$labels['ActionPlan'] = _t('MonthlyReviewRequest.ActionPlan', "Action Plan:");
$labels['PromotionTarget'] = _t('MonthlyReviewRequest.PromotionTarget', "Promotion Target:");
$labels['Leadership'] = _t('MonthlyReviewRequest.Leadership', "Leadership:");
$labels['DevelopmentPoints'] = _t('MonthlyReviewRequest.DevelopmentPoints', "Development Points:");
$labels['TrainingAndHelp'] = _t('MonthlyReviewRequest.TrainingAndHelp', "Training & Help:");
$labels['OtherPoints'] = _t('MonthlyReviewRequest.OtherPoints', "Other Points");
$labels['SaveReviewForm'] = _t('MonthlyReviewRequest.SaveReviewForm', "Submit Review");
return $labels;
}
public function sendMonthlyReviewRequestToSireEmail()
{
FrontendEmail::create()->sendMonthlyReviewRequestToSireEmail($this, MonthlyReviewRequest $monthlyreviewrequest, ContentController $controller);
}
public function providePermissions()
{
return array(
"VIEW_MONTHLY_REVIEW" => "View Monthly Review",
);
}
}
There's also a third file, that creates a CRM menu and redirects from this menu to form: http://pastebin.com/BCu4dtw3
Where's the error? I'm fighting with this bug all day long...
The first parameter of FormAction
should specify the controller function that should process the form on submission.
In your code your FormAction
action is set to saveReviewForm
. saveReviewForm
needs to be a function on your controller, not on your form.
Also note your getCustomFormActions
function incorrectly sets the FormAction
action to 'MonthlyReviewRequest.SubmitReview'
.