Skip to content

radio_button and checkbox generate inconsistent markup when id is specified #342

@lcreid

Description

@lcreid

If the caller specifies a DOM id to radio_button or checkbox, the generated label's for attribute is the "Rails default" id, rather than the custom one. For example, this code:

radio_button(:misc, '1', label: 'This is a radio button', id: "custom_id")

generates:

 <label for="user_misc_1"><input id="custom_id" name="user[misc]" type="radio" value="1"/> This is a radio button</label>

You could argue that the expect output should be:

<label for="custom_id"><input id="custom_id" name="user[misc]" type="radio" value="1"/> This is a radio button</label>

Since the label actually wraps the form control, I don't believe this affects how the page behaves. It does affect the test cases I'm writing for #326, but I can work around the problem in the meantime. I just wanted to put this out in there in case someone sees it as potentially being an issue.

I will submit a pull request with test cases that expose this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions