我有一个名为ForgotPasswordPage.php的自定义页面和一个ForgotPasswordPage.ss模板。我还在ForgotPasswordForm.php中有一个自定义Form类,它是模板/ Includes目录中相应的自定义表单模板ForgotPasswordForm.ss。 表单操作应该调用doForgotPassword,但这个函数永远不会被调用,否则,我会被发送到google.com。 这似乎永远那么基本的,但我已经有两个开发人员看着它和所有我们得到的是以下错误:Silverstripe 3.1为自定义表单执行操作不执行
似乎一直是一个技术问题。请点击后退按钮,刷新浏览器,然后重试。
我在这里做错了什么?
ForgotPasswordForm.php
<?php
class ForgotPasswordForm extends Form {
function __construct($controller, $name, $arguments=array()) {
$fields = new FieldList(
EmailField::create("Email")
);
$actions = new FieldList(FormAction::create("doForgotPassword")->setTitle("RETRIEVE PASSWORD"));
$validator = new RequiredFields('Email');
parent::__construct($controller, $name, $fields, $actions, $validator);
}
public function doForgotPassword($data, Form $form) {
//As a test, if we ever get here, the controller should send me to the Google website
Controller::curr()->redirect('http://www.google.com');
}
public function forTemplate() {
return $this->renderWith(array(
$this->class,
'Form'
));
}
}
ForgotPasswordForm.ss
<form $FormAttributes>
<label for="{$FormName}_Email">Enter Your Email Address</label>
$Fields.dataFieldByName(Email)
<% if $Actions %>
<% loop $Actions %>
$Field
<% end_loop %>
<% end_if %>
</form>
ForgotPasswordPage.php
class ForgotPasswordPage extends Page {
.
.
.
}
class ForgotPasswordPage_Controller extends Page_Controller {
public static $allowed_actions = array (
'MyForgotPasswordForm'
);
public function init() {
parent::init();
}
public function MyForgotPasswordForm(){
return new ForgotPasswordForm($this, 'MyForgotPasswordForm');
}
}
ForgotPasswordPage.ss
.
.
.
$MyForgotPasswordForm
.
.
.
谢谢 - 完美的工作! – user3324692
在主silverstripe.org网站论坛上发布您的解决方案以及 http://www.silverstripe.org/form-questions/show/41149#post337798 再次感谢! – user3324692