<div class="modal modal-form" tabindex="-1" role="dialog">
    <div class="modal-dialog">
        <form name="userEditForm" class="form-horizontal group-border-dashed" novalidate>
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" ng-click="$hide()">&times;</button>
                    <h4 class="modal-title" ng-bind="title"></h4>
                </div>
                <div class="modal-body">
                    <div class="content">
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.username.$invalid && !userEditForm.username.$pristine}">
                            <label class="col-sm-3 control-label">Username</label>
                            <div class="col-sm-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
                                    <input type="text" name="username" class="form-control" ng-model="edit_user.username" required>
                                </div>
                                <p ng-show="userEditForm.username.$invalid && !userEditForm.username.$pristine" class="help-block">
                                    Please enter a valid username.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.password.$invalid}">
                            <label class="col-sm-3 control-label">Password</label>
                            <div class="col-sm-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
                                    <input type="password" name="password" class="form-control" ng-model="edit_user.password">
                                </div>
                                <p ng-show="userEditForm.password.$invalid" class="help-block">
                                    Please enter a valid password.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.password_confirm.$invalid}">
                            <label class="col-sm-3 control-label">Re-enter Password</label>
                            <div class="col-sm-6">
                                <div class="input-group">
                                    <span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
                                    <input type="password" name="password_confirm" class="form-control" ng-model="edit_user.password_confirm">
                                </div>
                                <p ng-show="userEditForm.password_match.$invalid" class="help-block">
                                    Please re-enter a valid matching password.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.first_name.$invalid && !userEditForm.first_name.$pristine}">
                            <label class="col-sm-3 control-label">First Name</label>
                            <div class="col-sm-6">
                                <input type="text" name="first_name" class="form-control" ng-model="edit_user.first_name" required>
                                <p ng-show="userEditForm.first_name.$invalid && !userEditForm.first_name.$pristine" class="help-block">
                                    Please enter a valid First Name.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.last_name.$invalid && !userEditForm.last_name.$pristine}">
                            <label class="col-sm-3 control-label">Last Name</label>
                            <div class="col-sm-6">
                                <input type="text" name="last_name" class="form-control" ng-model="edit_user.last_name" required>
                                <p ng-show="userEditForm.last_name.$invalid && !userEditForm.last_name.$pristine"
                                   class="help-block">
                                    Please enter a valid Last Name.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.billing.address.$invalid && !userEditForm.billing.address.$pristine}">
                            <label class="col-sm-3 control-label">Address</label>
                            <div class="col-sm-6">
                                <input type="text" name="billing_address" class="form-control" ng-model="edit_user.address" required>
                                <p ng-show="userEditForm.billing.address.$invalid && !userEditForm.billing.address.$pristine"
                                   class="help-block">
                                    Please enter a valid address.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.billing.address_2.$invalid && !userEditForm.billing.address_2.$pristine}">
                            <label class="col-sm-3 control-label">Address 2</label>
                            <div class="col-sm-6">
                                <input type="text" name="billing_address_2" class="form-control" ng-model="edit_user.address_2">
                                <p ng-show="userEditForm.billing.address_2.$invalid" class="help-block">
                                    Please enter a valid address 2.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.billing.city.$invalid && !userEditForm.billing.city.$pristine}">
                            <label class="col-sm-3 control-label">City</label>
                            <div class="col-sm-6">
                                <input type="text" name="city" class="form-control" ng-model="edit_user.city" required>
                                <p ng-show="userEditForm.billing.city.$invalid && !userEditForm.billing.city.$pristine" class="help-block">
                                    Please enter a valid city.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.billing.state.$invalid && !userEditForm.billing.state.$pristine}">
                            <label class="col-sm-3 control-label">State/Province</label>
                            <div class="col-sm-6">
                                <select ng-required="true" ui-select2 ng-model="edit_user.state"
                                        name="billing_state" id="billing_user_states" data-placeholder="Select State">
                                    <option value=""></option>
                                    <option ng-repeat="state in states" value="{{state.id}}">{{state.name}}</option>
                                </select>
                                <p ng-show="userEditForm.billing.state.$invalid && !userEditForm.billing.state.$pristine"
                                   class="help-block">
                                    Please choose a valid state.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.postal_code.$invalid && !userEditForm.postal_code.$pristine}">
                            <label class="col-sm-3 control-label">Postal Code</label>
                            <div class="col-sm-6">
                                <input type="text" name="billing_postal_code" class="form-control" ng-model="edit_user.postal_code" required>
                                <p ng-show="userEditForm.billing.postal_code.$invalid && !userEditForm.postal_code.billing.$pristine"
                                   class="help-block">
                                    Please enter a valid postal code.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.telephone.$invalid && !userEditForm.telephone.$pristine}">
                            <label class="col-sm-3 control-label">Telephone</label>
                            <div class="col-sm-6">
                                <input type="phone" name="telephone" class="form-control" ng-model="edit_user.telephone">
                                <p ng-show="userEditForm.telephone.$invalid && !userEditForm.telephone.$pristine" class="help-block">
                                    Please enter a valid phone number.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.mobile.$invalid}">
                            <label class="col-sm-3 control-label">Mobile</label>
                            <div class="col-sm-6">
                                <input type="phone" name="mobile" class="form-control" ng-model="edit_user.mobile">

                                <p ng-show="userEditForm.mobile.$invalid"
                                   class="help-block">
                                    Please enter a valid phone number.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.group.$invalid && !userEditForm.group.$pristine}">
                            <label class="col-sm-3 control-label">Group</label>
                            <div class="col-sm-6">
                                <select ng-required="true" ui-select2 ng-model="edit_user.group" multiple
                                        name="group" id="user_group" data-placeholder="Select Group">
                                    <option ng-repeat="group in groups" value="{{group.id}}">{{group.name}}</option>
                                </select>
                                <p ng-show="userEditForm.group.$invalid && !userEditForm.group.$pristine" class="help-block">
                                    Please enter a valid group for this user.
                                </p>
                            </div>
                        </div>
                        <div class="form-group"
                             ng-class="{'has-error': userEditForm.active.$invalid && !userEditForm.active.$pristine}">
                            <label class="col-sm-3 control-label">Active</label>
                            <div class="col-sm-6">
                                <input icheck class="icheck" data-size="small" ng-model="edit_user.active" type="checkbox" name="is_active" checked/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button ng-click="updateUser(edit_user)" type="submit" class="btn btn-primary" ng-disabled="userEditForm.$invalid">Save</button>
                    <button ng-click="$hide()" class="btn btn-default">Cancel</button>
                </div>
            </div>
        </form>
    </div>
</div>