在Dataobject中提交表单

编程入门 行业动态 更新时间:2024-10-28 21:22:50
本文介绍了在Dataobject中提交表单-Silverstripe 3.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用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中提交表单

本文发布于:2023-10-07 17:56:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1470096.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   Dataobject

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!