heartcombo / simple_form

Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.
http://blog.plataformatec.com.br/tag/simple_form
MIT License
8.21k stars 1.31k forks source link

Unexpected number showed before label #1005

Closed slemrmartin closed 10 years ago

slemrmartin commented 10 years ago

Rails: 3.2.16 Simple form: 2.0.1

I'm using simple form like this: <%= f.input :block %> in model: validates_numericality_of :block, greater_than_or_equal_to: 1, less_than_or_equal_to: 5, :allow_blank => false

Then in HTML there is text "5" before label (regardless if I have default label, or not). Form is created with ajax call, code in chrome console is like following:

<div class="input integer optional">5<label class="integer optional" for="etm_school_program_seminar_block"> Block</label><input class="numeric integer optional" id="etm_school_program_seminar_block" max="5" min="1" name="etm_school_program_seminar[block]" step="1" type="number" value="1"></div>

I don't know how to remove this "5" text

rafaelfranca commented 10 years ago

Could you create an example application producing this bug? Nothing in our code seems to generate this number.

slemrmartin commented 10 years ago

I'll try, but it takes some time. Cannot do now. Thanks for fast response

slemrmartin commented 10 years ago

I identified this problem after debugging: In /gems/simple_form-2.0.1/lib/simple_form/wrappers/many.rb>render#L30: There is iteration over components. There are components:

call stack:

rafaelfranca commented 10 years ago

Yes, it generates the number 5, but in min and max options and only on this. https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/components/min_max.rb#L7-8

Could you create the example application to help us to debug?

slemrmartin commented 10 years ago

do you need source code of example app or some deployed app? I don't have heroku accounts etc (and my app is in not an open source, so I cannot share neither url nor code)

rafaelfranca commented 10 years ago

Only the source code

slemrmartin commented 10 years ago

ok, there it is http://ulozto.cz/xmM6gzDH/simple-form-app-zip

rafaelfranca commented 10 years ago

Could you post the application code on github?

slemrmartin commented 10 years ago

hm, sorry, don't know how

slemrmartin commented 10 years ago

wait a second...:)

slemrmartin commented 10 years ago

https://github.com/slemrmartin/simple_form_app

slemrmartin commented 10 years ago

Ouch, it's only simple form 2.0.1 bug (obviously). I don't see it in 2.1.1. So I'm sorry, thanks for your time, I have to initiate updates in my company

rafaelfranca commented 10 years ago

You are right. It is only v2.0. It was fixed at https://github.com/plataformatec/simple_form/commit/c4db622757905b750f9b55038b8704e0dbf9caaf if you want to monkey patch it