formapro / JsFormValidatorBundle

The Javascript validation for Symfony 2, 3 and 4 forms
MIT License
128 stars 57 forks source link

TypeError: element is null #46

Closed dawidvdh closed 10 years ago

dawidvdh commented 10 years ago

Hi, I seem to be having some trouble implementing the validation, currently using:

Symfony - 2.5 jsformvalidator-bundle - 1.2

here is how i have implemented it thus far:

{{ include('FpJsFormValidatorBundle::javascripts.html.twig') }} - in the head

and then the form is being called like so: {{ render(controller('SignUpFormBundle:Default:signUp')) }}

and in that it looks like:

{{ init_js_validation() }} {{ form_start(form) }}

{{ form_widget(form.nameAndSurname) }}
        <div class="form-row">
            {{ form_widget(form.email) }}
        </div>
        <div class="form-row split-row">
            {{ form_widget(form.captcha) }}
                {{ form_widget(form.submit) }}
            </div>

{{ form_rest(form) }} {{ form_end(form) }}

But i keep getting this error when the page loads: TypeError: element is null if (element.domNode && 'form' == element.domNode.tagName.toLowerCase()) {

Any Help Greatly Appreciated.

jumale commented 10 years ago

hi @dawidvdh try to render your whole form by one function {{ form(form) }} if in this case it works fine, then you have missed some important part of html structure of your form. Read this doc - in general, the form, its children and all the nested children should have their own DOM elements in your document, with related id.

dawidvdh commented 10 years ago

Thank you, works perfectly.