在@@个人信息视图上隐藏自定义字段
我正在按照 Collective.examples.userdata 在注册表单上添加一些自定义字段。
其中一个字段是“接受条款”,ceuserdata 也有该字段和文档,正如 包中所述描述(或者至少我是这样理解的)特殊的“接受条款”字段应该只显示在注册表上,而不应该显示在@@个人信息视图上。
我还尝试在我的构建中添加一个全新的 Plone 站点,它也显示在 @@personal-information 上,所以我想知道这是我的误解还是那里存在错误。
有人知道如何在@@注册表单上显示字段但在@@个人信息上隐藏它吗?
I'm following collective.examples.userdata to add some custom fields on the register form.
One field is the "accept terms", which the c.e.userdata also has and documents, and as said on the package description (or at least I understood that way) the special "Accept Terms" field should only be shown on the registration form but not on the @@personal-information view.
I also tried adding c.e.userdata on my buildout with a fresh new Plone site and it's also shown on @@personal-information, so I'm wondering if it's a misunderstood from me or that there's a bug there.
Anyone knows how to show a field on the @@register form but hide it on @@personal-information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不支持直接在
@@personal-information
表单中隐藏字段并仅在@@register
表单上显示该字段,仅支持其他方式大约。您必须自定义一种或另一种形式才能完成此任务;自定义 plone.app.users.browser.personalpreferences.UserDataPanel 以删除您的字段,或提供新版本的 plone.app.users.browser.register.RegistrationForm 以在其中添加您的字段。
我的做法如下:
注意
.omit('acceptTerms')
,我必须猜测您的额外字段的名称。然后,您可以在您的主题浏览器层上使用 ZCML 注册此自定义面板,或者直接在您的 Plone 站点或自定义界面上注册。这里我采取简单的方法并将其注册为 Plone 站点对象:这应该适用于 Plone 4.0 和 4.1,因为这个特定的类没有改变。
Hiding a field from the
@@personal-information
form and only show it on the@@register
form is not supported out-of-the-box, only the other way around.You'll have to customize either the one or the other form to accomplish this; customize plone.app.users.browser.personalpreferences.UserDataPanel to remove your field or provide a new version of plone.app.users.browser.register.RegistrationForm to add your field there.
Here's how I'd do it:
Note the
.omit('acceptTerms')
, I had to guess at the name of your extra field. You can then register this customized panel with ZCML against your theme browser layer, or directly on your Plone site or a custom interface. Here I take the easy way out and register it for the Plone site object:This should work for both Plone 4.0 and 4.1, as this particular class did not change.