Search code examples
ruby-on-railsruby-on-rails-4formtastic

Lock the size of a text_area input in Formtastic


I want to lock the size of my text area inputs in Formtastic, to get rid of the little "hook" or "handle" on the bottom right of each box that allows you to resize the box beyond the space it takes up as set by column and row settings.

I'm guessing it's the "autogrow" class that needs to be changed to something else like "fixed" or "solid", but nothing I try works, and I can't find a single relevant Stack Overflow question that describes what can be substituted as an alternative to "auto grow".

I can't find anything about it in the Formtastic Documentation.

#view/something.html.erb
<div class="col-md-8">
  <%= f.input :comment_specify, label: "Comment (maximum 300 characters)", :input_html => { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 300  } %>
</div>
<!-- ./col-md-8 --> 

the row, column and max length settings all work perfectly.

I'm using Bootstrap 3 and Rails 4.


Solution

  • Use style="resize:none;overflow:hidden"

    i.e

    #view/something.html.erb
      <div class="col-md-8" style="resize:none;overflow:hidden">
          <%= f.input :comment_specify, label: "Comment (maximum 300 characters)",
    
     :input_html=> { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 300  }
    
      %>
     </div>
     <!-- ./col-md-8 -->