我需要在SilverStripe中将一些数据从表单传递到数据库,但是当我单击“发送”按钮时,我得到的只是重新加载带有空白字段的表单,当然db中没有数据。这是表单文件的代码(在此处粘贴到代码标记中太长了):http://pastebin.com/KHnZug9Z
这就是DataObject文件的样子:
/**
* 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",
);
}
}
还有第三个文件,用于创建CRM菜单并从此菜单重定向到:http://pastebin.com/BCu4dtw3
哪里出错?我整天都在和这个虫子斗争......
答案 0 :(得分:0)
FormAction
的第一个参数应指定应在提交时处理表单的控制器函数。
在您的代码中,您的FormAction
操作设置为saveReviewForm
。 saveReviewForm
需要在您的控制器上执行,而不是在您的表单上。
另请注意,您的getCustomFormActions
功能错误地将FormAction
操作设置为'MonthlyReviewRequest.SubmitReview'
。