Sha256: 64299845c2cc20622d32fb2af4966635e7824641b0f5049ee8b84a1adc87c000

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module Capybara
  module ActiveAdmin
    module Finders
      # Finders for *active_admin_form_for* and related form components.
      module Form
        # @param model_name [Class<Object>, String, nil] form record class or model name (default nil).
        # @yield within form
        def within_form_for(model_name = nil)
          selector = form_selector(model_name)
          within(selector) { yield }
        end

        # @param association_name [String]
        # @param index [String] index of fieldset, starts with 0 (default 0).
        # @yield within fieldset>ol
        def within_form_has_many(association_name, index: 0)
          selector = has_many_fields_selector(association_name)
          fieldset = find_all(selector, minimum: index + 1)[index]

          within(fieldset) { yield }
        end

        # @yield within filters container.
        def within_filters
          selector = filter_form_selector
          within(selector) { yield }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara_active_admin-0.3.3 lib/capybara/active_admin/finders/form.rb
capybara_active_admin-0.3.2 lib/capybara/active_admin/finders/form.rb