【发布时间】:2014-03-18 16:32:58
【问题描述】:
我有一个名为 ForgotPasswordPage.php 的自定义页面和一个 ForgotPasswordPage.ss 模板。我在 ForgotPasswordForm.php 中还有一个自定义表单类,它是相应的自定义表单模板 ForgotPasswordForm.ss,位于模板/包含目录中。 表单操作应该调用 doForgotPassword,但永远不会调用此函数,否则,我会被发送到 google.com。 这似乎非常基本,但我有两个开发人员正在查看它,我们得到的只是以下错误:
似乎出现了技术问题。请点击返回按钮,刷新浏览器,然后重试。
我在这里做错了什么?
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
.
.
.
【问题讨论】:
标签: php forms silverstripe