乌节路:自定义字段中注册 [英] Orchard: Custom Registration fields

查看:125
本文介绍了乌节路:自定义字段中注册的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的果园的项目,我需要在注册时用户一些额外的信息。 (喂,姓,名,裤子的颜色)。而注册和(根据客户订单为)不能被推迟到以后必须输入这些信息。

For my Orchard project, I need some additional information from the user at registration time. (Say, First Name, Last Name, Pants Color). This information must be entered while registering and can not be deferred until later (as per client's orders).

我尝试使用配置文件和扩展插件注册索要这些,但据我看到的,这只是给了我可选字段登记表中显示。有没有一种办法是强制present领域?

I tried using the Profile and Extended Registration plugins to ask for those, but as far as I see, this only gives me optional fields to display in the registration form. Is there a way to present fields that are mandatory?

我也有一个快速进军覆盖的AccountController的注册方法,根据的这个讨论,但我无法得到它的工作:控制器是在不同的地方,它不能被继承,即使我迫使它,永远不会执行code 。我presume他们正在使用的果园更旧版本。

I also had a quick foray into overwriting the AccountController's Register method, as per this discussion, but I couldn't get it to work: The controller is in a different place, it can't be subclassed and even if I force it to, code is never executed. I presume they are using a much older version of Orchard.

所以,在哪个方向,我应该去建立一个强制性的字段,靠近乌节理念是什么?我应该创建,也许拒绝空值的新字段类型? (是,甚至有可能)?

So, in which direction should I go to create a mandatory field that is close to the Orchard philosophy? Should I create a new field type that rejects empty values maybe? (is that even possible)?

推荐答案

我写的,因为那同样需要的ExtendedRegistration模块。
您需要创建一个自定义的一部分,例如:MyRegistrationPart。
然后添加该部分用户的ContentType。
在你的一部分就在[必填]属性(数据注解)添加到是强制性的任何属性。
注册将不会成功,直到这些强制值已填写!

I wrote the ExtendedRegistration module because of that same need. You need to create a custom part, e.g.: MyRegistrationPart. Then you add that part to the User ContentType. In your part just add the [Required] attribute (Data annotations) to any properties that are mandatory. Registration will not succeed until those mandatory values have been filled out!

希望它现在清楚了。

这篇关于乌节路:自定义字段中注册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆