
<div wire:ignore>
    <div class="card">
        <div class="card-header">
            Build Your Own Form
        </div>
        <div class="card-body">
            <label for="name"><?php echo e(__('Form Title')); ?></label>
            <input type="hidden" id="update_id" name="update_id" value="<?php echo e($editId ?: ''); ?>" class="form-control" />
            <input type="text" id="name" name="name" value="<?php echo e($editData->name ?? ''); ?>" class="form-control" required/>
            <!--[if BLOCK]><![endif]--><?php if($errors->has('name')): ?>
                <span class="text-danger"><?php echo e($errors->first('name')); ?></span>
            <?php endif; ?><!--[if ENDBLOCK]><![endif]-->
            <div id="fb-editor" class="mt-4"></div>
            <!--[if BLOCK]><![endif]--><?php $__errorArgs = ['form'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> <span class="text-danger"><?php echo e($message); ?></span> <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?><!--[if ENDBLOCK]><![endif]-->
        </div>
    </div>
</div>

    <?php
        $__assetKey = '3792777288-0';

        ob_start();
    ?>
    <script src="<?php echo e(URL::asset('js/jquery-ui-1.13.2.min.js')); ?>"></script>
    <script src="<?php echo e(URL::asset('assets/form-builder/form-builder.min.js')); ?>"></script>
    <?php
        $__output = ob_get_clean();

        // If the asset has already been loaded anywhere during this request, skip it...
        if (in_array($__assetKey, \Livewire\Features\SupportScriptsAndAssets\SupportScriptsAndAssets::$alreadyRunAssetKeys)) {
            // Skip it...
        } else {
            \Livewire\Features\SupportScriptsAndAssets\SupportScriptsAndAssets::$alreadyRunAssetKeys[] = $__assetKey;
            \Livewire\store($this)->push('assets', $__output, $__assetKey);
        }
    ?>
    <?php
        $__scriptKey = '3792777288-1';
        ob_start();
    ?>
<script>
  $(document).ready(function() {
        var fbEditor = document.getElementById('fb-editor');
        var formBuilder = $(fbEditor).formBuilder({
            fieldRemoveWarn: true,
            onSave: function(evt, formData) {
                var updateId = $("#update_id").val() != '' ? true : false;
                saveForm(formData,updateId);
            },
        });
        
        function saveForm(form,updateId) {
            try {
                var nameValue = $("#name").val();
                if (nameValue.trim() == '') {
                    alert('Name field required!');
                    return false;
                }else if(form.length === 0){
                    alert('Form field required!');
                    return false;
                }

                $wire.set('name',nameValue);
                $wire.set('content',form);
                if (updateId) {
                    $wire.update();
                }else{
                    $wire.create();
                }
            } catch (error) {
                console.error("An error occurred:", error);
            }
        }

        <?php if(!empty($editData->content)) {?>
            setTimeout(() => {
                var jsonData = <?php echo \Illuminate\Support\Js::from($editData->content)->toHtml() ?>;
                formBuilder.actions.setData(jsonData);
            }, 2500);
        <?php } ?>
  });
</script>
    <?php
        $__output = ob_get_clean();

        \Livewire\store($this)->push('scripts', $__output, $__scriptKey)
    ?><?php /**PATH C:\laragon\www\marketing_data_analysis\resources\views/livewire/form-builder/create.blade.php ENDPATH**/ ?>