Skip to content

db text column as radio button fails javascript-side with validates_presence_of #28

tec opened this Issue Dec 3, 2009 · 1 comment

2 participants

tec commented Dec 3, 2009

I have a column :sex in the user table which is a text field in the database.
And a formtastic form that renders it as
<%= form.input :sex, :as => :radio, :label => 'Title', :collection => [["Mr.", 'male'], ["Mrs.", 'female']], :required => true %>

When I add "validates_presence_of :sex" to the model then all client-side validation fails. OnLoad of the html a javascript error occurs. Firebug says the following (I don't know if that helps):

this.__elements[0] is undefined
G()()v2.stand...259591608 (Linie 7)
G()()v2.stand...259591608 (Linie 7)
G()()v2.stand...259591608 (Linie 7)
G()(Object __events=[2] __elements=[0] __monitored=true, Object __name=presence __message=can't be blank, [], undefined)v2.stand...259591608 (Linie 7)
G()()v2.stand...259591608 (Linie 7)
G()(Object __name=presence __message=can't be blank, [], undefined)v2.stand...259591608 (Linie 7)
G()([Object validator=Object params=[0] invert=false 0=Object], Object __validators=[0] __errors=[0] __passOnAny=false, "")v2.stand...259591608 (Linie 7)
G()(form#user_form.validate users, Object __validators=[0] __errors=[0] __passOnAny=false, [])v2.stand...259591608 (Linie 7)
G()(form#user_form.validate users)v2.stand...259591608 (Linie 7)
G()()v2.stand...259591608 (Linie 7)
G()()v2.stand...259591608 (Linie 7)
G()()v2.stand...259591608 (Linie 7)
[Break on this error] var addDOMLoadEvent=(function(){var F=[]...getElementsByTagName("input")[0]:A)}}});

grimen commented Dec 3, 2009

OK, no I actually have no clue what that can be. =/ Validatious-On-Rails is far from "complete" (not meant to be used in production yet), and right now I'm trying to finalize the code base refactoring (major one that makes it' trivial to extend with custom model validations). Haven't had much time to spend on this project this month though, but just got started a bit again so I probably won't prioritize JavaScript stuff until I'm satisfied with the "behind the scenes" stuff. Would be awesome if you could trace the reason for this, I haven't experienced any similar one myself. Actually I hope more people could join in on solving JavaScript issues as I'm more of a JavaScript amateur myself. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.