I have on one page 2 forms for the model User
- and this is the problem, why I am getting the error Uncaught TypeError: Cannot read property 'presence' of undefined
. When I remove one form_for @user, so the Client Side Validations works well. But not if on one page are two models and two forms @user.
But the problem is, that I need to have on one page this model and form twice. Is there any way to solve this problem?
For me, the second error you describe in the comments, i.e. Uncaught TypeError: Cannot read property 'first_user[name]' of undefined
was apparently caused by a transposed form ID.
There is an issue on ClientSideValidation about it here:
https://github.com/bcardarella/client_side_validations/issues/325
Adding html => { id: 'user_new' }
to the form_for
call solved the issue. I now call the method like this (modified from Devise's original template):
<%= form_for(resource,
:as => resource_name,
:validate => true,
:html => { id: 'user_new' },
:url => registration_path(resource_name)) do |f| %>
HTH.