0

Just set up ActiveAdmin without any real issues, but when I get to any edit/create forms, I get a small issue:

I have an attribute for my users called "shortcut_url" which defines only the path to the users' page i.e. example.com/userjohn where userjohn would be the shortcut url. Activeadmin recognizes the attribute as a URL and won't let me create a user validating that "userjohn" is nopt a valid URL. I commend ActiveAdmin for being smart enough to catch "url" in the attribute name, but in this case, I'd rather not have this validation. Does anyone know where I can find a place to override this validation? I poked through the documentation, but to no avail... Any help would be appreciated!

Kyle Macey
  • 8,074
  • 2
  • 38
  • 78

1 Answers1

3

I think it's actually formtastic which determines the input type. To override the validation you just need to change the input type. I had an issue with this with a field called "website" (it kept saying my url wasn't allowed).

Here's an example of app/admin/user.rb:

  form do |f|
    f.inputs do
      f.input :name
      f.input :website, :as => :string # sets the input type to type="text"
    end
  f.buttons
  end

It's actually just some styles that come built in with active_admin. I know for sure they have validations on type="url" and type="email". There's probably a better way around it (disabling the style in the stylesheets) but this will get you going.

Ryan

ryanjones
  • 5,383
  • 4
  • 28
  • 24
  • In addendum to the above, it's because Rails 3 ships with html5 controls. That's the actual popup we're seeing. By changing the type, it make sit so it's no html5 anymore. There is a way to disable html5 in forms, I haven't looked into it with formtastic yet. – ryanjones Feb 13 '12 at 23:59
  • Me again. Here's how you can disable html5 validation on a form or fields: http://stackoverflow.com/questions/7065917/add-attribute-to-rails-helper-text-field – ryanjones Feb 24 '12 at 04:01