Skip to content

If I use bootstrap_form_tag I get fields id starts with underscore #241

@shell362

Description

@shell362

Suppose we use bootstrap_form_tag:

= bootstrap_form_tag url: categories_path_generator(@category), method: :get do |f|
  = f.select :region, StaticData::REGIONS.map.with_index {|index, region| [index, region] }, include_blank: true, selected: params[:region]

Then I got strange id of any field starts with underscore:

id="_region"

If I try to use form namespace, like this:

namespace: :ads_form

I also get strange id with double underscore in the middle:

id="ads_form__region"

I saw the code, it looks like you use form_for without model instead to use form_tag in that case. And first one makes this underscore because is waiting for model/record name.

Also I can't set id of any field manually:

f.text_field :region, id: 'ads_field_region'
or
f.text_field :region, html: { id: 'ads_field_region' }

In both cases I get id generated by form_for:

id="_region"

Bug or feature?

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