Activeadmin and Formtastic: form not responding to :size
Solution 1
I am not sure if your question is solved or not.
However according to Formastic Official WIKI, your code should work:
Customize HTML attributes for any input using the :input_html option. Typically this is used to disable the input, change the size of a text field, change the rows in a textarea, or even to add a special class to an input to attach special behavior like autogrow textareas:
<%= semantic_form_for @post do |f| %>
<%= f.inputs do %>
<%= f.input :title, :input_html => { :size => 10 } %>
<%= f.input :body, :input_html => { :class => 'autogrow', :rows => 10, :cols => 20, :maxlength => 10 } %>
<%= f.input :created_at, :input_html => { :disabled => true } %>
<%= f.input :updated_at, :input_html => { :readonly => true } %>
<% end %>
<%= f.actions %>
<% end %>
https://github.com/justinfrench/formtastic
if your code doesn't work , please check out the error logs, or put more debug info to your erb file, to see if you r rails is running under production mode.
Solution 2
i had the same problem. i wanted a nested form for edit with custom text field size.this worked for me.
form do |f|
f.inputs "Header" do
cf.input :name, :input_html => { :class => 'some_style', :rows => 2, :style => 'width:50%'}
end
f.actions
end
so basically u have to create your own class or just work with the :style.
For nested form u can use this code
form do |f|
f.inputs "Header" do
f.has_many :name,:allow_destroy => true,:new_record => true do |cf|
cf.input :first_name, :input_html => { :class => 'some_style', :rows => 2, :style => 'width:50%'}
end
end
f.actions
end
Mark Tuttle
Updated on July 06, 2022Comments
-
Mark Tuttle almost 2 years
I am trying to format a form and the text fields respond to some methods, and not others.
I can do things like:
f.input :name, :input_html => { :maxlength => 10 } f.input :name, :input_html => { :disabled => true }
But if I try to do any of the following, they do not work:
f.input :name, :input_html => { :size => 10 } f.input :name, :input_html => { :class => 'autogrow' } f.input :name, :input_html => { :rows => 10, :cols => 10 }
When I try using :size, for instance, the generated html shows that size=10, but is not reflected in the actual form.
These were more or less pulled right from the Formtastic documentation on Github, which the Activeadmin documentation refers to.
-
Serge Vinogradoff over 10 yearsFor me this doesn't work. Rows and class do get to the textarea, but don't do anything.. I'm using Foundation Zurb.
-
songyy almost 9 yearsIt didn't work for my case either. I'm using activeadmin with a partial for generating the form
-
Siwei almost 9 yearsactive admin is evil...let's forget it... ^_^
-
Nick Res over 6 yearsActiveAdmin is good for very simple projects because not for huge projects that require a great deal of customization. So much re-learning and depending on their poor documentation makes it extremely frustrating to work with.