简体   繁体   中英

Customize the size of a text field in Rails with twitter-bootstrap-rails gem

In Rails 5, I have a text input field which is styled using Bootstrap with the twitter-bootstrap-rails gem.

<div class='container'>
  </div class='form-control'>
  <%= form_tag pages_home_path, remote:true, id: 'submit-text-button' do %>
    <%= text_field_tag :text, params[:text], :required => 'required', class: 'form-control' %>
    <%= submit_tag 'Submit your text', class: 'btn btn-primary btn-lg btn-block' %></div>
  <% end %>
  </div>
</div>

Normally I would have done some thing like:

<textarea class='form-control' cols="186" rows="10" required="required" name="text"></textarea>

but I'm not sure how this translates to Rails. I tried different solutions but nothing worked. Any ideas? Thanks!

Try this ...

<div class='container'>
  </div class='form-control'>
  <%= form_tag pages_home_path, remote:true, id: 'submit-text-button' do %>
    <%= text_area_tag :text, params[:text], :required => 'required', class: 'form-control', :rows => 10 %>
    <%= submit_tag 'Submit your text', class: 'btn btn-primary btn-lg btn-block' %></div>
  <% end %>
  </div>
</div>

and you can also add size

<%= text_area_tag :text, params[:text], :required => 'required', class: 'form-control', :size =>"25x10" %>

here cols=25 and rows=10

Hope this will work for you. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM