Sha256: 0fa7cbf1cba5a58defcf5be67938ce9251b59efb41ec2c19b0c3bea663a6e73e

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

module Capybara
  module ActiveAdmin
    module Finders
      module Form
        # @param name [Class<Object>, String] form record class or model name
        def within_form_for(name)
          name = name.model_name.singular if name.is_a?(Class)
          selector = form_selector(name)
          within(selector) { yield }
        end

        # @param association_name [String]
        # @param index [String] index of fieldset, starts with 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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capybara_active_admin-0.2.1 lib/capybara/active_admin/finders/form.rb
capybara_active_admin-0.2.0 lib/capybara/active_admin/finders/form.rb