252 lines
12 KiB
PHP
252 lines
12 KiB
PHP
@extends('backend.template')
|
|
@section('content')
|
|
<!-- start page title -->
|
|
<div class="row">
|
|
|
|
|
|
<div class="col-12">
|
|
<div class="page-title-box d-sm-flex align-items-center justify-content-between">
|
|
<h4 class="mb-sm-0">Add New Form</h4>
|
|
|
|
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Dashboards</a></li>
|
|
<li class="breadcrumb-item active">Add New Form</li>
|
|
</ol>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<form action="{{route('forms.store')}}" id="my-form" method="POST">
|
|
@csrf
|
|
<div class="row">
|
|
|
|
<div class="col-xl-9">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div>
|
|
{{createText("title","title","Title")}}
|
|
<h5 class="fs-14 mt-2 mb-3 text-muted">Parmalink: <a href="#" target="_blank">http://localhost/bibadmin/bibcms/about.php</a> </h5>
|
|
</div>
|
|
<div class="border mt-3 border-dashed mb-3"></div>
|
|
{{createTextarea("text","text ckeditor-classic","Description")}}
|
|
|
|
</div>
|
|
</div>
|
|
<div class="card">
|
|
<div class="card-header"><h4 class="card-title mb-0">Add Custom Field</h4></div>
|
|
<div class="card-body">
|
|
<div id="repeater-container"></div>
|
|
<div id="add-button-container"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-header"><h4 class="card-title mb-0">Email Notification</h4></div>
|
|
<div class="card-body">
|
|
|
|
<div class="row">
|
|
<div class="col-lg-6">{{createText("headers","headers","Headers")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("toemail","toemail","To Email")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("fromemail","fromemail","From Email")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("emailsubject","emailsubject","Email Subject")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("emailtext","emailtext","Email Text")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("autoresponse","autoresponse","Auto Response")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("responseheaders","responseheaders","Response Headers")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("responsefrom","responsefrom","Response From")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("responsesubject","responsesubject","Response Subject")}}
|
|
</div>
|
|
<div class="col-lg-6">{{createText("responsetext","responsetext","Response Text")}}
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-xl-3">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title mb-0">Featured Image</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="col-lg-12 pb-2">{{createImageInput("cover_photo","Cover Photo")}}
|
|
</div>
|
|
<div class="border border-dashed mb-3"></div>
|
|
<div class="col-lg-12 pb-2">{{createImageInput("image_thumb","Image Thumb")}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title mb-0">Published</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="form-check form-switch form-switch-lg form-switch-success mb-3" dir="ltr">
|
|
<input type="checkbox" class="form-check-input" id="customSwitchsizelg" checked="">
|
|
<label class="form-check-label" for="customSwitchsizelg">Active</label>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer">
|
|
|
|
<?php createButton("btn-primary btn-store", "", "Submit"); ?>
|
|
<?php createButton("btn-danger btn-cancel", "", "Cancel", route('forms.index')); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
@endsection
|
|
@push("js")
|
|
<script>
|
|
createFormFieldsRepeater();
|
|
// addFormField();
|
|
|
|
// const addButtonContainer = document.getElementById('add-button-container');
|
|
|
|
|
|
function createFormFieldsRepeater() {
|
|
const repeaterContainer = document.getElementById('repeater-container');
|
|
const addButtonContainer = document.getElementById('add-button-container');
|
|
|
|
// Add button
|
|
const addButton = document.createElement('button');
|
|
addButton.textContent = 'Add Field';
|
|
addButton.addEventListener('click', addFormField);
|
|
addButtonContainer.appendChild(addButton);
|
|
|
|
// Repeater fields
|
|
let fieldCount = 0;
|
|
|
|
function addFormField() {
|
|
event.preventDefault();
|
|
fieldCount++;
|
|
|
|
// Create form field container
|
|
const fieldContainer = document.createElement('div');
|
|
fieldContainer.classList.add('form-field');
|
|
fieldContainer.classList.add('row');
|
|
const fieldInputContainer = document.createElement('div');
|
|
fieldInputContainer.classList.add("col");
|
|
fieldInputContainer.innerHTML = ("<label for=\"fieldName\" class=\"form-label col-form-label\"> Field Name </label>");
|
|
const fieldNameInput = document.createElement('input');
|
|
fieldNameInput.setAttribute('type', 'text');
|
|
fieldNameInput.setAttribute('name', `fieldNames[]`);
|
|
fieldNameInput.setAttribute('placeholder', 'Field Name');
|
|
fieldInputContainer.classList.add('col');
|
|
fieldNameInput.classList.add('form-control');
|
|
fieldInputContainer.appendChild(fieldNameInput);
|
|
fieldContainer.appendChild(fieldInputContainer);
|
|
|
|
// Field Type select
|
|
const fieldInputContainers2 = document.createElement('div');
|
|
fieldInputContainers2.classList.add("col");
|
|
fieldInputContainers2.innerHTML = ("<label for=\"fieldName\" class=\"form-label col-form-label\"> Field Type </label>");
|
|
|
|
const fieldTypeSelect = document.createElement('select');
|
|
fieldTypeSelect.setAttribute('name', `fieldTypes[]`);
|
|
const textOption = document.createElement('option');
|
|
textOption.setAttribute('value', 'text');
|
|
textOption.textContent = 'Text';
|
|
|
|
fieldTypeSelect.appendChild(textOption);
|
|
|
|
const textareaOption = document.createElement('option');
|
|
textareaOption.setAttribute('value', 'textarea');
|
|
textareaOption.textContent = 'Textarea';
|
|
fieldTypeSelect.appendChild(textareaOption);
|
|
fieldTypeSelect.classList.add('col');
|
|
fieldTypeSelect.classList.add('form-control');
|
|
fieldInputContainers2.appendChild(fieldTypeSelect);
|
|
fieldContainer.appendChild(fieldInputContainers2);
|
|
|
|
// Field Default input
|
|
const fieldInputContainer3 = document.createElement('div');
|
|
fieldInputContainer3.classList.add("col");
|
|
fieldInputContainer3.innerHTML = ("<label for=\"fieldName\" class=\"form-label col-form-label\"> Default Value </label>");
|
|
const fieldDefaultInput = document.createElement('input');
|
|
fieldDefaultInput.setAttribute('type', 'text');
|
|
fieldDefaultInput.setAttribute('name', `fieldDefaults[]`);
|
|
fieldDefaultInput.setAttribute('placeholder', 'Field Default Value');
|
|
fieldDefaultInput.classList.add('col');
|
|
fieldDefaultInput.classList.add('form-control');
|
|
fieldInputContainer3.appendChild(fieldDefaultInput);
|
|
fieldContainer.appendChild(fieldInputContainer3);
|
|
|
|
// Field CSS input
|
|
const fieldInputContainer4 = document.createElement('div');
|
|
fieldInputContainer4.classList.add("col");
|
|
fieldInputContainer4.innerHTML = ("<label for=\"fieldName\" class=\"form-label col-form-label\"> Extra CSS </label>");
|
|
const fieldCssInput = document.createElement('input');
|
|
fieldCssInput.setAttribute('type', 'text');
|
|
fieldCssInput.setAttribute('name', `fieldCss[]`);
|
|
fieldCssInput.classList.add('form-control');
|
|
fieldInputContainer4.appendChild(fieldCssInput);
|
|
fieldContainer.appendChild(fieldInputContainer4);
|
|
|
|
// Remove button
|
|
const fieldInputContainer5 = document.createElement('div');
|
|
fieldInputContainer5.classList.add("col");
|
|
fieldInputContainer5.innerHTML = ("<label for=\"fieldName\" class=\"form-label col-form-label\">   <span class=\"row-selector-handle\">☰</span></label>");
|
|
const removeButton = document.createElement('button');
|
|
removeButton.textContent = 'Remove Field';
|
|
removeButton.classList.add('btn');
|
|
removeButton.classList.add('btn-danger');
|
|
removeButton.classList.add('col');
|
|
removeButton.classList.add('form-control');
|
|
removeButton.addEventListener('click', () => {
|
|
repeaterContainer.removeChild(fieldContainer);
|
|
});
|
|
fieldInputContainer5.appendChild(removeButton);
|
|
fieldContainer.appendChild(fieldInputContainer5);
|
|
|
|
repeaterContainer.appendChild(fieldContainer);
|
|
makeSortable();
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
<!-- jQuery library -->
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
|
|
<!-- jQuery UI Sortable library -->
|
|
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>
|
|
|
|
<!-- Add the CSS for jQuery UI Sortable (optional, but recommended for styling) -->
|
|
<link rel="stylesheet" href="https://code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css">
|
|
|
|
<script>
|
|
function makeSortable(){
|
|
$(document).ready(function () {
|
|
// Make the repeater-container sortable
|
|
$("#repeater-container").sortable({
|
|
axis: "y", // Allow sorting only vertically
|
|
handle: ".row-selector-handle", // Define the handle element for dragging (form-field class)
|
|
containment: "parent", // Keep the sorting within the repeater-container
|
|
});
|
|
|
|
// Disable text selection while dragging to avoid text highlighting
|
|
$("#repeater-container").disableSelection();
|
|
});
|
|
}
|
|
</script>
|
|
@endpush
|