Module: Capybara::ActiveAdmin::Selectors::Form

Included in:
Capybara::ActiveAdmin::Selectors
Defined in:
lib/capybara/active_admin/selectors/form.rb

Overview

Selectors for active_admin_form_for and related form components.

Instance Method Summary collapse

Instance Method Details

#filter_form_selectorString

Returns selector.

Returns:

  • (String)

    selector.



59
60
61
# File 'lib/capybara/active_admin/selectors/form.rb', line 59

def filter_form_selector
  '.filter_form'
end

#form_selector(model_name = nil) ⇒ String

Returns selector.

Parameters:

  • model_name (String, nil) (defaults to: nil)

    form model name

Returns:

  • (String)

    selector.



10
11
12
13
14
15
# File 'lib/capybara/active_admin/selectors/form.rb', line 10

def form_selector(model_name = nil)
  return 'form.formtastic' if model_name.nil?

  model_name = Util.parse_model_name(model_name, singular: true)
  "form.formtastic.#{model_name}"
end

#form_submit_selector(text = nil) ⇒ String

Returns selector.

Parameters:

  • text (String, nil) (defaults to: nil)

    submit button text.

Returns:

  • (String)

    selector.



40
41
42
43
44
# File 'lib/capybara/active_admin/selectors/form.rb', line 40

def form_submit_selector(text = nil)
  return %(input[type="submit"]) if text.nil?

  %(input[type="submit"][value="#{text}"])
end

#has_many_fields_selector(association_name) ⇒ String

Returns selector.

Parameters:

  • association_name (String)

Returns:

  • (String)

    selector.



34
35
36
# File 'lib/capybara/active_admin/selectors/form.rb', line 34

def has_many_fields_selector(association_name)
  "div.has_many_container.#{association_name} > fieldset.inputs.has_many_fields"
end

#inline_error_selectorString

Returns selector.

Returns:

  • (String)

    selector.



23
24
25
# File 'lib/capybara/active_admin/selectors/form.rb', line 23

def inline_error_selector
  'p.inline-errors'
end

#input_container_selector(label = nil, exact: nil) ⇒ String

Returns selector.

Parameters:

  • label (String, nil) (defaults to: nil)

    field label.

  • exact (Boolean, nil) (defaults to: nil)

    match by exact label text (default false).

Returns:

  • (String)

    selector.



49
50
51
52
53
54
55
56
# File 'lib/capybara/active_admin/selectors/form.rb', line 49

def input_container_selector(label = nil, exact: nil)
  return 'li' if label.nil?

  label_opts = Util.options_with_text(label, exact: exact)
  label_node = find(label_selector, label_opts)
  li_id = label_node.ancestor('li')[:id]
  "li##{li_id}"
end

#label_selectorString

Returns selector.

Returns:

  • (String)

    selector.



18
19
20
# File 'lib/capybara/active_admin/selectors/form.rb', line 18

def label_selector
  'label.label'
end

#semantic_error_selectorString

Returns selector.

Returns:

  • (String)

    selector.



28
29
30
# File 'lib/capybara/active_admin/selectors/form.rb', line 28

def semantic_error_selector
  'ul.errors > li'
end