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

"hide_label: true" on select element does not update the element's parent div class to col-sm-12. #34

Closed
davelens opened this issue Jan 9, 2014 · 2 comments

Comments

@davelens
Copy link

davelens commented Jan 9, 2014

Hello! Really digging this gem so far, but I have a question:

# in my view:
f.select :parent_id, options_for_parents(@page), {}, hide_label: true
<!-- Generated HTML from the view: -->
<div class="form-group">
  <label class="sr-only col-sm-2 control-label" for="page_parent_id">Hoofdniveau</label>
  <div class="col-sm-10">
    <select class="form-control" id="page_parent_id" name="page[parent_id]">
    ...
    </select>
  </div>
</div>

I was wondering if there is a way with the current codebase to circumvent the behaviour so that whenever I set hide_label: true, it will change the select parent's class to col-sm-12 instead of col-sm-10. I can do it with a few lines of JavaScript, but would prefer it in Ruby.

This is what I would like to end up with:

<div class="form-group">
  <!-- The label may be removed in this case -->
  <div class="col-sm-12">
    <select class="form-control" id="page_parent_id" name="page[parent_id]">
    ...
    </select>
  </div>
</div>
@potenza
Copy link
Member

potenza commented Jan 9, 2014

hi @davelens, currently there isn't a way to do this without hacking it.

I've thought about adding the ability to mix styles (both stacked and horizontal), which would allow you to use a stacked control for the parent_id and then hide the label so it effectively takes up the entire width.

However, we're currently working on merging this gem with bootstrap_forms over at https://github.com/bootstrap-ruby/rails-bootstrap-forms, so I'm not sure if this is something we'd be able to get to for a while.

@davelens
Copy link
Author

Alright, thank you for the reply!

I'll close this and work around it with JS for now.

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

2 participants