Skip to content

Mongoid embedded document boolean selector does not work #3554

@rpalackas

Description

@rpalackas

Describe the bug
When a mongoid document has an embedded class the boolean selector doesn't work on new or edit

Reproduction steps
Create mongoid class with embedded document
Embedded document needs to have a Mongoid::Boolean field
Add the embedded document in accepts_nested_attributes_for
Open edit or create for the parent document in rails admin
Clicking any of the buttons for the boolean won't change your selection

Expected behavior
Clicking the buttons will change the selection

Additional context
Digging into the html it seems to be that the label field has an incorrect for value:
What rails admin creates:

<input class="btn-check" type="radio" value="1" name="parent_class[embedded_class_attributes][field_name]" id="parent_class_embedded_class_attributes_field_name_1">
<label for="parent_class[embedded_class_attributes]_field_name_1" class="success btn btn-outline-success">
<span class="fas fa-check"></span>
</label>

What it should be:

<input class="btn-check" type="radio" value="1" name="parent_class[embedded_class_attributes][field_name]" id="parent_class_embedded_class_attributes_field_name_1">
<label for="parent_class_embedded_class_attributes_field_name_1" class="success btn btn-outline-success">
<span class="fas fa-check"></span>
</label>

manually updating that label tag for attribute via admin tools fixes the problem.

  • rails version: 6.1.6.1
  • rails_admin version: 3.0.0
  • mongoid version: 7.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions