Disabling a input field prevents simple form from submitting values

2,270 views
Skip to first unread message

Bharat

unread,
Feb 22, 2012, 5:53:55 PM2/22/12
to SimpleForm
I have a fax rate field in my application that is looked up whenever
the user selects or changes a state field from a drop down. I look it
up using ajax and then grey out the field using coffeescript. The
problem is: the looked-up value is not submitted when I click the
submit button. How can I get simple_form to submit the value?
Thanks in advance for your time.
Bharat

Rafael Mendonça França

unread,
Feb 22, 2012, 6:21:14 PM2/22/12
to plataformate...@googlegroups.com
When you said grey out the field are you disabling it?

Please sent us a code snippet to make the things more clear.

Bharat

unread,
Feb 22, 2012, 6:36:15 PM2/22/12
to SimpleForm
Hello Rafael,
Thanks for your response. When I said greyed out, I meant I was
setting the disabled attribute to true using Javascript. I have been
doing some research online and found the following two responses
including Carlo's answer.

http://groups.google.com/group/plataformatec-simpleform/browse_thread/thread/5e669542b0b0a380/a6ad0ef9d15b6ec5?lnk=gst&q=disabled+fields#a6ad0ef9d15b6ec5

and

http://stackoverflow.com/questions/5620128/rails-not-editable-text-field

Trouble is, I don't know how to set readonly attribute using
simple_form. So here is the code snippet:

= f.input :oil_rate, :input_html => {:size => 15}, :readonly =>
true

and this doesn't work either:

= f.input :oil_rate, :input_html => {:size => 15, :readonly =>
true}

How can I use the readonly attrubute with simple form?

Bharat

Bharat

unread,
Feb 22, 2012, 6:53:23 PM2/22/12
to SimpleForm
Hello Rafael,
Apologies. the following code indeed make the field readonly:

= f.input :oil_rate, :input_html => {:size => 15}, :readonly => true

I was confused since it did not grey it out, i.e., shade the color
grey as it does when it is disabled. But when I try to edit it, it
wouldn't let me which is precisely what I want. I guess, I can use
the css to grey it out manually?

Thanks.

Bharat

Rafael Mendonça França

unread,
Feb 22, 2012, 6:54:35 PM2/22/12
to plataformate...@googlegroups.com
Yeah. You need to change the CSS.
Reply all
Reply to author
Forward
0 new messages