具有Angular验证的Symfony表单,即使表单正常,也会禁用该按钮

时间:2017-02-20 19:38:07

标签: angularjs validation symfony

与标题一样,我有一个symfony表单,由angular

验证
<div ng-controller="RegistrationController">
    <div class="text-center row bottom-buffer"><h3>Registration form</h3></div>
    {{ form_start(form, {'attr':{'novalidate':''}}) }}
    <div class="form-group">
        {{ form_widget(form.name, {'attr':{'ng-model':'registration.name','required':'','class':'form-control text-center', 'placeholder': 'name'|trans}}) }}
        <div ng-show="userbundle_user.$submitted || userbundle_user['userbundle_user[name]'].$touched">
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[name]'].$error.required">{% trans %}
                this field is required{% endtrans %}</div>
        </div>
    </div>
    <div class="form-group">
        {{ form_widget(form.surname, {'attr':{'ng-model':'registration.surname','required':'', 'class':'form-control text-center', 'placeholder': 'surname'|trans}}) }}
        <div ng-show="userbundle_user.$submitted || userbundle_user['userbundle_user[surname]'].$touched">
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[surname]'].$error.required">{% trans %}this field is
                required{% endtrans %}</div>
        </div>
    </div>
    <div class="form-group">
        {{ form_widget(form.username, {'attr':{'ng-model':'registration.username','required':'', 'class':'form-control text-center', 'placeholder': 'username'|trans}}) }}
        <div ng-show="userbundle_user.$submitted || userbundle_user['userbundle_user[username]'].$touched">
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[username]'].$error.required">{% trans %}this field is
                required{% endtrans %}</div>
        </div>
    </div>
    <div class="form-group">
        {{ form_widget(form.country, {'attr':{'class':'form-control text-center', 'placeholder': 'country'|trans}}) }}
    </div>
    <div class="form-group">
        {{ form_widget(form.city, {'attr':{'class':'form-control text-center', 'placeholder': 'city'|trans}}) }}
    </div>
    <div class="form-group">
        {{ form_widget(form.email, {'attr':{'ng-model':'registration.email','required':'', 'class':'form-control text-center', 'placeholder': 'email'|trans }}) }}
        <div ng-show="userbundle_user.$submitted || userbundle_user['userbundle_user[email]'].$touched">
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[email]'].$error.required">{% trans %}this field is
                required{% endtrans %}</div>
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[email]'].$error.email">{% trans %}e-mail not
                valid{% endtrans %}</div>
        </div>
    </div>
    <div class="form-group">
        {{ form_widget(form.password.first, {'attr':{'ng-model':'registration.password_first','required':'','class':'form-control text-center', 'placeholder': 'password'|trans}}) }}
        <div ng-show="userbundle_user.$submitted || userbundle_user['userbundle_user[password][first]'].$touched">
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[password][first]'].$error.required">{% trans %}this field
                is
                required{% endtrans %}</div>
        </div>
    </div>
    <div class="form-group">
        {{ form_widget(form.password.second, {'attr':{'ng-model':'registration.password_second','required':'', 'class':'form-control text-center', 'placeholder': 'repeat-password'|trans}}) }}
        <div ng-show="userbundle_user.$submitted || userbundle_user['userbundle_user[password][second]'].$touched">
            <div class="text-danger text-center"
                 ng-show="userbundle_user['userbundle_user[password][second]'].$error.required">{% trans %}this
                field is
                required{% endtrans %}</div>
        </div>
    </div>
    <div class="form-group">
        {{ form_widget(form.description, {'attr':{'class':'form-control text-center', 'rows':'5', 'placeholder': 'description'|trans}}) }}
    </div>
    <div class="form-group">
        {{ form_widget(form.avatar, {'attr':{'class':'center-block'}}) }}
    </div>
    <div class="form-group">
        {{ form_widget(form.submit, {'attr':{'ng-enabled':'userbundle_user.$valid', 'class':' form-control btn btn-primary'}}) }}
    </div>
    {{ form_end(form) }}
</div>

当我正确填写所有字段时,仍然按钮不起作用,当我点击它时,没有任何反应。

当我禁用角度时,表单正在工作,按钮正在提交等。

0 个答案:

没有答案