Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tec opened this issue Dec 3, 2009 · 1 comment

Comments

@tec
Copy link

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
http://localhost:3000/javascripts/v2.standalone.full.min.js?1259591608
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
Copy link
Owner

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
Projects
None yet
Development

No branches or pull requests

2 participants