Skip to content

inline: true on collection_ Methods Doesn't Generate the Right CSS #777

@lcreid

Description

@lcreid

inline: true on collection_ methods, at least for checkboxes and radio buttons, gives different CSS from a form with layout: :inline. The incorrect markup is even in the test case.

  test "collection_check_boxes renders inline checkboxes correctly" do
    collection = [Address.new(id: 1, street: "Foo"), Address.new(id: 2, street: "Bar")]
    expected = <<~HTML
      <input #{autocomplete_attr_55336} id="user_misc" name="user[misc][]" type="hidden" value="" />
      <div class="mb-3">
        <label class="form-label" for="user_misc">Misc</label> # FIXME: Form `layout: inline` gives "form-check form-check-inline ps-0"
        <div class="form-check form-check-inline">
          <input class="form-check-input" id="user_misc_1" name="user[misc][]" type="checkbox" value="1" />
          <label class="form-check-label" for="user_misc_1">
            Foo
          </label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input" id="user_misc_2" name="user[misc][]" type="checkbox" value="2" />
          <label class="form-check-label" for="user_misc_2">
            Bar
          </label>
        </div>
      </div>
    HTML

    assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
                                                                     inline: true)
  end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions