can't change the height of a text field in simple_form

前端 未结 8 1644
耶瑟儿~
耶瑟儿~ 2021-02-19 02:22

I\'ve tried

  #Default size for text inputs.  
  config.default_input_size = 10

from config/initializers/simple_form.rb

I\'ve also tri

相关标签:
8条回答
  • 2021-02-19 02:43

    You need to do this

    <%= f.input :message, :input_html => {:rows => 10} %>
    

    Html text area tag attributes has two attributes namely rows and cols which lets you specify the no of rows and columns(i.e. width) of your text area. If this is not working then open the console and see if your css is overriding the height.

    0 讨论(0)
  • 2021-02-19 02:47

    Old question, I know. This is what worked for me with SimpleForm 3.2.0 and Rails 4.2.3:

    <%= f.input_field :field_name, as: :text, class: "my-custom-class", rows: 5 %>
    
    0 讨论(0)
  • 2021-02-19 02:48

    if you want to change "height", you need to modify css attribute:

    <%= f.input :message, input_html: {style: 'height:10px;'} %>
    
    0 讨论(0)
  • 2021-02-19 02:49

    Try Firebug or Code Inspector from Google Chrome to inspect the text_field element, see the exactly class name and change it directly in your stylesheet file.

    0 讨论(0)
  • 2021-02-19 02:50

    You can do

    <%= f.input :message, :size => "10x10" %>
    

    for height and width.

    It might work for text field but definitely works for text_area. You probably would want to use text_area for a message anyway.

    0 讨论(0)
  • 2021-02-19 02:52

    I managed to do this by adding :as => :text to the input field attributes and then adding style & rows to the input html:

    <%= f.input :message, label: "Message: ", :as => :text, input_html: { :style=> 'width: 100%;', :rows => 4} %>
    

    For me it was the :as => :text that got the "rows" attribute to work, and the 100% width made it fluid rather than fixed-width.

    0 讨论(0)
提交回复
热议问题