Orchard: Custom Registration fields

佐手、 提交于 2019-12-05 10:58:24

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!

Hope it's clear now.

While this probably won't answer your question just wanted to point out that it is my understanding that you don't need to override/subclass the AccountController class. Instead you need to "overwrite" the Users/Account/Register route by adding your own with a higher priority. To do that you need to implement an IRouteProvider as part of our module. Since it's an IDependency it will be loaded and processed automagically at run time. Something like:

public class Routes : IRouteProvider
{
    public void GetRoutes(ICollection<RouteDescriptor> routes)
    {
        routes.AddRange(GetRoutes());
    }

    public IEnumerable<RouteDescriptor> GetRoutes()
    {
        return new[] {
            new RouteDescriptor {
                // Make sure to be higher than the default
                Priority = ##### PRIORITY HERE (int) ######,
                Route = new Route(
                "Users/Account/Register",
                new RouteValueDictionary {
                    {"area", "#### YOUR MODULE AREA HERE ####"},
                    {"controller", "#### YOUR ACCOUNT CONTROLLER HERE ####"},
                    {"action", "#### YOUR REGISTER ACTION HERE ####"}
                },
                new RouteValueDictionary(),
                new RouteValueDictionary {
                    {"area", "#### YOUR MODULE AREA HERE ####"}
                },
                new MvcRouteHandler())
            }
        };
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!