在devise_invitable的邀请形式中添加自定义字段的验证
据我所知,devise 仅对电子邮件和密码进行验证,可以在初始化程序 devise.rb 中重新配置:
# ==> Configuration for :validatable
# Range for password length. Default is 6..128.
# config.password_length = 6..128
# Regex to use to validate the email address
# config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
如何添加已添加到 devise_invitable 邀请形式中的自定义字段的验证?
例如,我需要验证表单中的名字和姓氏:
= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name) do |f|
= f.input :first_name
= f.input :last_name
= f.input :email
= f.button :submit
提前致谢!
As I know, devise has validation only for email and password, which can be reconfigurated in initializer devise.rb:
# ==> Configuration for :validatable
# Range for password length. Default is 6..128.
# config.password_length = 6..128
# Regex to use to validate the email address
# config.email_regexp = /\A([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})\z/i
How add validation for custom fields, which has been added into invitation form of devise_invitable?
For example, I need validation for the first_ and the last_ names in the form:
= simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name) do |f|
= f.input :first_name
= f.input :last_name
= f.input :email
= f.button :submit
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论