I’m on a crunch (first) project in rails. My deadline is Friday, and I’ve lost all modesty about posting dumb questions etc. Please help if you can…
I’m using form_for to create a form associated with my model. That works. I’m using bootstrap for the overall site design. That works. The problem: I am having a hell of time formatting the form (e.g. getting checkboxes, text fields, and radio buttons to be inline, all at once). Also if the page is refreshed, any inline formatting I happened to accomplish goes away, and bootstrap default layouts are taking over. Relevant line of code here is:
<%= form_for @student, url: {action: "create"}, html: {class: "form-inline"} do |f| %>
And for the form items I’m using things like…
<%= f.label :phone_number, "Phone Number" %>
<%= text_field(:student, :phone_number) %></br></br>
<%= f.radio_button(:device_type, value: 1) %>
<%= label :device_type, 'I like this button and want to select it', :value => 1 %></br>
<%= f.check_box(:active, value: 1, checked: false) %>
<%= f.label(:active, "I have reviewed and agree to the Terms of Use") %>
I know that’s not perfect code above, but I’ve tried a million combinations.
So anyone have advice? What’s the best way to accomplish: bootstrap + form associated with my model + control over the layout like inline elements, including that they stay inline after a page refresh, which happens if the user data doesn’t pass validation.
I see gems like simple_form, formtastic for bootstrap and so on but I really was looking for a non-gem solution just to simplify things, plus I don’t know which of those would be best for my situation. If you can’t tell, I’m not a designer but am playing one on this project.
Thanks!