<form action="<?php echo e(route('member.add_wife')); ?>" method="post" class="mt-2" id="addWifeForm" novalidate="novalidate">

    <?php echo csrf_field(); ?>

<div class="row align-items-center justify-content-center">
    <div class="col-md-12">
        <input type="hidden" name="member_id" value="<?php echo e($member_id); ?>">
        <div class="form-group">
            <label>Select Wife</label>

            <fieldset class="form-group">
                <select class="form-control select2" id="wife_id" name="wife_id" data-rule-required="true" data-msg-required="Select Wife">
                    <?php $__currentLoopData = $wives; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $wife): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option value="<?php echo e($wife->id); ?>"><?php echo e($wife->name); ?> (<?php echo e($wife->member_number); ?>)</option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </fieldset>
        </div>
    </div>
    
    <div class="col-auto">
        <div class="form-group text-right my-1">
            <button type="submit" class="btn btn-primary">Add</button>
        <button type="button" class="btn btn-dark btn-min-width mr-1" data-dismiss="modal">Cancel</button>

        </div>
    </div>
</div>

    


</form>

<script type="text/javascript">
    $(document).ready(function () {
        $('#wife_id').prepend('<option value="" selected="selected"></option>').select2({
                width: '100%',
                placeholder: 'Select Wife*',
                dropdownParent:$('#addWifeForm')
            });

        var errors = 0;
        
        $( "#addWifeForm" ).validate({


            errorClass:"danger",
            errorPlacement: function(error, element) {
                error.addClass('w-100').appendTo(element.parents('.form-group'));
            },
            submitHandler: function(form) {
                // $(form).find('button[type=submit]').attr('disabled', 'disabled');

                if(errors === 1){
                    return false;
                }else{
                    

                    swal({
                                    title: 'Are You Sure?',
                                    text: 'Select Yes to Add Wife!',
                                    icon: 'warning',
                                    buttons: {
                                        cancel: {
                                            text: 'No',
                                            value: null,
                                            visible: true,
                                            closeModal: true,
                                        },
                                        confirm: {
                                            text: 'Yes',
                                            value: true,
                                            visible: true,
                                            closeModal: true
                                        }
                                    },
                                    closeOnClickOutside: false,
                                    closeOnEsc: false,
                                    dangerMode: true
                                }).then(function (confirm) {
                                    if (confirm) {
                                       
                                        form.submit();

                                    }
                                });
                    $(form).find('button[type=submit]').attr('disabled', 'disabled');
                    // swal({
                    //     title: 'Please Wait!',
                    //     text: 'City is being updated!',
                    //     icon: 'info',
                    //     buttons: false,
                    //     closeOnClickOutside: false,
                    //     closeOnEsc: false
                    // });

                    // form.submit();
                }

            }
        });


    });
</script><?php /**PATH /home/aimpgorg/public_html/datasys/resources/views/member/add_wife.blade.php ENDPATH**/ ?>