Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to create radio button without label? #161

Closed
akolomiychuk opened this issue Oct 22, 2014 · 11 comments
Closed

Ability to create radio button without label? #161

akolomiychuk opened this issue Oct 22, 2014 · 11 comments

Comments

@akolomiychuk
Copy link

I want to achieve this html using form_builder

<div class="form-group">
  <label class="sr-only control-label" for="quiz_multiple_question_answer0">Answer0</label>
  <div class="input-group">
    <span class="input-group-addon">A</span>
    <input class="form-control form-control" id="quiz_multiple_question_answer0" name="quiz_multiple_question[answer0]" placeholder="Answer A" type="text">
    <span class="input-group-addon"><input id="quiz_multiple_question_solution_0" name="quiz_multiple_question[solution]" type="radio" value="0"> </span>
  </div>
</div>

with following code

f.text_field("answer#{i}".to_sym, class: 'form-control', placeholder: "Answer #{letters[i]}", hide_label: true, append: f.radio_button(:solution, i), prepend: "#{letters[i]}")

But seems that radio button cannot be created without label. I tested it on version 2.1.1, but seems that this is actual for current master too.

I already monkey-patched it locally(added no_label: true option), so I can create a PR if you approve that this is a feature which you want to have.

@onebree
Copy link

onebree commented Feb 26, 2015

@akolomiychuk I would like your monkey patch code for the no_label option. I am having the same option with checkboxes. I have a series of checkboxes inside a table, each column with a heading -- no need for a label. In the mean time, I have label: "", but now I cannot check the box in my specs... (Without selecting the box by a huge id.)

@soullivaneuh
Copy link

Got the same issue:

= f.form_group :active, label: { text: 'Active' } do
  = f.check_box :active, hide_label: true

Give me this:

checkbox_nolabel_not_expected

But I expected this:

checkbox_nolabel_expected

@akolomiychuk I would be happy to see this PR. But why not using the hide_label option instead of no_label?

@onebree
Copy link

onebree commented Apr 2, 2015

I agree, I would rather have hide_label, because it is still present in the document, for Capybara's sake, whereas no_label means no identifier.

@soullivaneuh on a side note, why does it say "1/12 tasks complete" under your referenced pull request? How do you enable tasks?

@soullivaneuh
Copy link

@onebree please take a look at this blog post: https://github.com/blog/1825-task-lists-in-all-markdown-documents 👍

@onebree
Copy link

onebree commented Apr 2, 2015

Okay, I have tried that in an opened issue on our app, but it was not read-only. (And this was a few weeks ago). It doesn't look like the read-only format has changed at all... ALSO, does the "tasks complete" thing only appear for PR, versus issues?

@soullivaneuh
Copy link

It's not read only if you are the issue owner, or project owner maybe. For the other, it's read only.

@akolomiychuk
Copy link
Author

Actually we can access default rails form builder helper using:

f.radio_button_without_bootstrap(:solution, i)

Also using label: '' for checkbox will produce proper html (http://getbootstrap.com/css/#checkboxes-and-radios-without-label-text).

@soullivaneuh
Copy link

@akolomiychuk Stop me if I'm wrong but it's just a workaround, isn't it?

With your method, we don't use bootstrap-forms at all, what is the advantage?

Thanks

@akolomiychuk
Copy link
Author

There is a 2 methods actually:

  1. If we need only checkbox/radio(input) you can use default form builder - cause you do not need TB there.
  2. If you want to make a checkbox/radio without label as from TB documentation - you can use label: '' and it'll produce the exact html.

So there is no issue with bootstrap-forms.

@onebree
Copy link

onebree commented Apr 23, 2015

@akolomiychuk As noted on the bootstrap site, saying label: '' does not work on inline forms, which appears to be what @soullivaneuh tries to do here: #161 (comment)

@soullivaneuh
Copy link

@onebree I think you're right. Have to test it again later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants