Does anyone know how to remove form labels? I have tried:
<%= comfy_form_for #comment, :as => :comment, options: {label: false}, :url => comfy_blog_comments_path(#cms_site.path, #blog.path, #post.slug) do |form| %>
also
<%= comfy_form_for #comment, :as => :comment, default: {label: false}, :url => comfy_blog_comments_path(#cms_site.path, #blog.path, #post.slug) do |form| %>
and also
<%= form.text_field :email, label: false, :class => 'form-control' %>
all to no avail...
ComfortableMexicanSofa is using https://github.com/bootstrap-ruby/rails-bootstrap-forms
So I think you need to do this:
<%= f.text_area :email, hide_label: true %>
Also for those wanting to completely remove the labels from the DOM, here is how to achieve it, according to rails-bootstrap-forms docs you should do the following:
HTML:
<%= form.text_area :content, :class => 'form-control', :rows => 5, placeholder: "Your comment", label_class: "removed-label" %>
CSS:
.removed-label {
display: none;
}
Hope it helps someone down the line.
Related
I have a selection option in my form that I know is deterring the form from submitting. I can't figure out why though. Here is the snippet that is causing an issue:
<%= f.select(:state_id, options_for_select(State.all.map {|p| [ p.home_state, p.id ]}), :label => "State", :class => "dropdown-menu")%>
Here is the rest of the form:
<% provide(:title, 'New Profile') %>
<%= bootstrap_form_for(#profile) do |f| %>
<%= f.text_field :name, :autofocus => true, :placeholder => 'Name' %>
<%= f.number_field :age, :placeholder => 'Age' %>
<%= f.form_group :sex, label: { text: "Sex" } do %>
<br>
<%= f.radio_button :sex, 'Male', label: "Male", inline: true %>
<%= f.radio_button :sex, 'Female', label: "Female", inline: true %>
<% end %>
<%= f.text_field :city, :id => 'gmaps-input-address', :placeholder => "City" %>
<%= f.select(:state_id, options_for_select(State.all.map {|p| [ p.home_state, p.id ]}), :label => "State", :class => "dropdown-menu")%>
<%= f.submit "Submit", :class =>'btn btn-primary' %>
<% end %>
Any help is always much appreciated.
If anything, you should look at the collection_select helper:
<%= bootstrap_form_for(#profile) do |f| %>
<%= f.text_field :name, autofocus: true, placeholder: 'Name' %>
<%= f.number_field :age, placeholder: 'Age' %>
<%= f.form_group :sex, label: { text: "Sex" } do %>
<%= f.radio_button :sex, 'Male', label: "Male", inline: true %>
<%= f.radio_button :sex, 'Female', label: "Female", inline: true %>
<% end %>
<%= f.text_field :city, :id => 'gmaps-input-address', placeholder: "City" %
<%= f.collection_select :state_id, State.all, :home_state, :id, prompt: "State", class: "dropdown-menu")%>
<%= f.submit "Submit", class: 'btn btn-primary' %>
<% end %>
You'll also want to post any console logs you may have received for the request. Remember that computers are logic-based, they're not emotional and will only stop working if there's an error. Your job is to find the error and fix it, hence showing what's going on with your code infinitely helps, where guesswork doesn't :)
I am working on a project using ruby 2 and rails 4. I want to create a progression bar in simple_form. I got some resources from https://github.com/aarondo/progression.js/blob/master/demo/index.html
and it does work perfectly. But it was created using html, and i want to create using simple_form_for. My codes are:
<%= simple_form_for #kyc do |f| %>
<h2>Personal Information</h2>
<%= f.input :first_name , placeholder: 'Type Your First Name', label:'First Name', required: true, input_html: { :value => ''}, autofocus: true %>
<%= f.input :last_name , placeholder: 'Type Your Last Name', label:'Last Name', required: true, input_html: { :value => ''} %>
<%= f.input :pan , placeholder: 'Type Your PAN No', label:'PAN', required: true, input_html: { :value => ''} %>
<p align="center"><%= f.submit "Save", id: "kycs_button" %></p>
<% end %>
Can any one please help me to solve this problem? Thank you.
The only thing I can spot right away is that you did not put the data-progression attribute in and you didn't put the data-helper
If you ommit the data-progression attribute, the progress-bar always stays at 0%
I can't get Data Abide to validate my fields in a modal (Foundation 5, Simple Form, Ruby on Rails).
Anyone know how to validate fields in a modal with AJAX using data-abide from Foundation?
<%= simple_form_for [current_user, #photo, #tag], id: "tagform", :remote => true do |f| %>
<div class="center semi_padding new_tag_form">
<%= f.input :name , label: "Marca: ", :required => "[a-zA-Z]+" ,input_html: {class: 'marca ipt'} %>
<%= f.input :location, label: "¿Donde lo encontraste?" , input_html: {class: 'ipt'} %>
<%= f.input :price, label: "¿Cuanto te costó?" , input_html: {class: 'ipt'} %>
<%= f.input :coordinate_x , as: :hidden %>
<%= f.input :coordinate_y , as: :hidden %>
<%= f.button :button, "Taggear", type: "button", id:"tp_tag_save", input_html: {class: 'btn-ok icon-favorite-1 button'} %>
<%= f.button :button, "Cancelar", name: "Cancel", id: "tp_tag_cancel", input_html: {class: 'icon-cancel button'} %>
</div>
<% end %>
Add this to your simple_form tag:
html: {novalidate: "novalidate", data: {abide: ''}
EX:
<%= simple_form_for [current_user, #photo, #tag], id: "tagform", :remote => true, html: {novalidate: "novalidate", data: {abide: ''} do |f| %>
Then make sure to throw in a reflow call on the form when the modal is triggered by adding the following JS to the click handler:
$(document).foundation('abide', 'reflow');
I have a simpleform for a 'post' object (like a blog post), and one of the form fields is for the 'tags' collection. 'Tags' are a has_and_belongs_to_many association with only one field besides the rails defaults, 'name'.
I want to have the user type in their tags, and then match them to existing tags, and then save them into the 'tags' array in the controller using first_or_create before saving the post object.
I really don't know how to design this. What is the best approach?
'Post' form:
<%= simple_form_for #post, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.input :shared_url, :required => false, input_html: { class: 'span6' } %>
<%= f.input :title, :required => false, input_html: { class: 'span6' } %>
<%= f.input :content, as: :text, :required => false, input_html: { class: 'span6' } %>
<%= f.input :tags, :required => false, input_html: { class: 'span6' } %>
<div class="form-actions">
<%= f.button :submit, "Post", :class => 'btn btn-primary btn-large' %>
</div>
<% end %>
I think you should checkout this railscast 196-nested-model-form-revised
I'm starting to use simple_form for a rails application, and while converting some of my forms, I came across one that has two models that it is working with, sort of an embedded form. Is this possible with simple_form?
<% simple_form_for :topic, :url => forum_topics_path do |t| %>
<%= t.input :name, :label => 'Topic' %></p>
<p>First Post:<br/></p>
Title: <%= text_field :post, :title %> <--- this is where i start having problems
Body: <%= text_area :post, :body %>
<%= t.submit 'Save' %>
Thanks
Use simple_fields_for :
<%= simple_form_for :topic, :url => forum_topics_path do |topic_builder| %>
<%= topic_builder.input :name, :label => 'Topic' %>
<%= topic_builder.simple_fields_for :post do |post_builder| %>
<p>First Post:</p>
<%= post_builder.input :title, :input_html => { :size => 30 } %>
<%= post_builder.input :body, :as => :text, :input_html => { :rows => 20, :cols => 50, :class => 'resizable' } %>
<% end %>
<%= topic_builder.submit 'Save' %>
<% end %>
Notes
Note the = symbol in <%= simple_form_for ... and <%= simple_fields_for (required in Rails 3.x)
Removed "Title:" and "Body:" text. Use the label generated for the inputs and style their location with CSS as needed.
Added example of using input_html
There's another approach that I'm using and it works great. Ryan Bates (RailsCasts) has created a gem to handle this.
See https://github.com/reu/simple_nested_form for the details.