Activeadmin and Formtastic: form does not respond to: size

I am trying to format a form, and text fields respond to some methods, 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 to use: size, for example, the generated html shows that size = 10 but does not display in the actual form.

They were more or less pulled directly from the Formtastic documentation on Github, to which the Activeadmin documentation belongs.

+7
source share
2 answers

I am not sure if your question is resolved or not.

However, according to the official official WIKI, your code should work:

Set the HTML attributes for any input using the: input_html parameter. This is usually used to disable input, resize the text box, change lines in the text box, or even add a special class to the input to attach special behaviors such as startup text areas:

 <%= 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, check the error logs or add additional debugging information to the erb file to see if r rails is working.

+11
source

I had the same problem. I need a nested editing form with a 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 you have to create your own class or just work with the style.

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 
+5
source

All Articles