Ruby on Rails Tuesday, September 1, 2015

> On Sep 1, 2015, at 11:41 AM, Abdulaleem Seyed <lists@ruby-forum.com> wrote:
>
> I am trying to add bootstrap styling to my rails form_for form. Such
> that I can change the button styling and make the from inline. I tried
> adding doing something like:
>
> <div class="form-group">
> <%= f.submit "Create your account", class: "btn btn-primary" %>
> </div>
>
> However, it did not work. Here is my code in my file.
>
> <%= form_for @subscription do |f| %>
> <%= f.text_field :email %>
> <%= f.submit %>
> <% end %>
>

When you view that in a browser, what do you see?

Bootstrap 3 doesn't require a classname on the form element itself any more, unless you want to do an inline form, in which case you need to add class="form-inline" to it. To do that in a standard Rails form_for helper, set that in the html: attributes:

<%= form_for :foo, html: { class: 'form-inline' } %>

The rest (form-group and similar) can be done easily with regular HTML inside the form partial, and you can add a classname to a form element like this:

<%= f.text_field :bar, class: 'form-control' %>

Walter

> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/738b375731807c87bfbd171efcb55b83%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/EA1878FC-AFA5-440C-ABE2-1649B39B1F54%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment