我正在使用Aram的DataobjectAsPage模块. 现在,我想在每个DOaP站点上都有一个表格.我在Dataobject中创建了这样的表单
I'm using the DataobjectAsPage Module from Aram. Now I want to have a Form on each DOaP site. I created the form like this in my Dataobject
public function RegistrationForm() { $fields = new FieldList( new TextField('Name'), new TextField('PlusOne') ); $actions = new FieldList( new FormAction('doRegistration', 'Submit') ); return new Form($this, 'RegistrationForm', $fields, $actions); } public function doRegistration($data, $form) { $submission = new RegistrationObject(); $form->saveInto($submission); $submission->EventObjectID = $this->ID; $submission->write(); return $this->redirectBack(); }我的Dataobject_show.ss模板看起来像这样
my Dataobject_show.ss Template looks like this
$RegistrationForm <% loop Registrations %> $Name - $PlusOne <% end_loop %>有表单,但没有提交数据.相同的形式适用于普通页面,但不适用于数据对象.我该如何解决?
the form is there but the data doesn't submit. The same form works on a normal page but not on a dataobject. how can i fix this?
提前谢谢
推荐答案您的RegistrationForm和doRegistration函数需要位于Holder页面控制器中,而不是数据对象中.
Your RegistrationForm and doRegistration functions need to be in your Holder page controller, not your data object.
这是因为数据对象页面实际上是由Holder控制器控制的.因此,如果您向该页面提交表单,则它实际上会提交给所有者页面.
This is because the data object page is actually controlled by the holder controller. So if you submit a form to this page, it actually submits to the holder page.
更多推荐
在Dataobject中提交表单
发布评论