<div wire:ignore>
    <div class="card col-8 m-auto">
        <div class="card-header d-flex justify-content-between">
            <p>Form/Table Name: <span class="text-primary">{{$form->name}}</span></p>
            <a href="{{url($from)}}" class="btn btn-secondary btn-sm align-self-center" wire:navigate><i class="fas fa-long-arrow-alt-left"></i> Back</a>
        </div>
        <div class="card-body p-5">
            <form method="POST" id="myForm" enctype="multipart/form-data">
                @csrf
                <input type="number" id="form_id" name="form_id" value="{{$form->id}}" hidden />
                <input type="text" id="update_id" name="update_id" value="{{$updateId}}" hidden />
                <div id="fb-reader"></div>
                <input type="submit" value="Save" class="btn btn-success" />
            </form>
        </div>
    </div>
</div>

@assets
    <script src="{{ URL::asset('js/jquery-ui-1.13.2.min.js') }}"></script>
    <script src="{{ URL::asset('assets/form-builder/form-render.min.js') }}"></script>
@endassets
@script
<script>
  $(document).ready(function() {
        $('#fb-reader').formRender({
            formData: {{ Js::from($content) }}
        });
    });


    $(document).ready(function () {
        $('#myForm').submit(function (e) {
            e.preventDefault(); // Prevent default form submission

            // Send Ajax request
            $.ajax({
                url: '{{ URL('save-form-data') }}',
                type: "POST",
                data:  new FormData(this),
                contentType: false,
                cache: false,
                processData:false,
                beforeSend:function(){					

                },
                success: function (response) {
                    if (response.status) {
                        $("#myForm")[0].reset();
                        alert(response.message);
                    }
                },
                error: function (error) {
                    console.error('Error submitting form:', error);
                }
            });
        });
    });

</script>
@endscript