سؤال

How can I set up my ActiveAdmin forms to use client side validation? More specifically, how do I pass the :validate => true option that Client Side Validation needs to the form method specified in Active Admin?

هل كانت مفيدة؟

المحلول

I guess the only way is to use the ActiveAdmin form partials http://activeadmin.info/docs/5-forms.html

  ActiveAdmin.register Post do
    form :partial => "form"
  end

/app/views/admin/posts/_form.hrml.erb

  <%= semantic_form_for [:admin, @post], remote: true, validate: true do |f| %>
    <%= f.inputs :title, :body %>
    <%= f.actions :commit %>
  <% end %>

EDIT if a form in ActiveAdmin is in partial that you want to customize, you can use rails form builder form_for instead of semantic_form_for:

<%= form_for @post, :validate => true do |f| %>
  <%= f.submit 'Submit' %>
<% end %>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top