Skip to content

Commit

Permalink
Dynamic Creation Form (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenGix authored and AliRn76 committed Feb 9, 2025
1 parent ce53da4 commit 5767a28
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions panther/panel/templates/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ <h1 class="text-2xl font-semibold mb-6">Create New Record</h1>
</div>

<script>
// Example fields object
const fields = [
{ title: 'Id', type: ['string', 'null'], required: false },
{ title: 'Books', type: ['array'], required: true },
{ title: 'Is Male', type: ['boolean', 'null'], required: true },
{ title: 'Name', type: ['string'], required: true },
{ title: 'Person', type: ['$Person', 'null'], required: false },
];
const fields = JSON.parse('{{fields|tojson|safe}}');
const fieldsObject = fields.fields;
const fieldsArray = Object.entries(fieldsObject).map(([key, value]) => ({
title: value.title || key,
type: value.type || [],
required: value.required || false,
}));

const dynamicInputsContainer = document.getElementById('dynamicInputs');

function generateInputs() {
fields.forEach(({ title, type, required }) => {
fieldsArray.forEach(({ title, type, required }) => {
let inputField;

if (Array.isArray(type)) {
Expand Down

0 comments on commit 5767a28

Please sign in to comment.