reading json file and create form at runtime lazarus / 21-General ---------------------------------------------------------------------- Packs · 2024-10-03 06:34 I want to read json file and create a form object at runtime . anyone tried this type of coding . with validation on submit form too Code: Javascript  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [    {    sectionTitle: 'User Information',      fields: [        {          name: 'fullName',          label: 'Full Name',          type: 'text',          required: true,          placeholder: 'Enter full name',      },        {          name: 'email',          label: 'Email Address',          type: 'email',          required: true,          placeholder: 'Enter email',        },        {          name: 'password',          label: 'Password',          type: 'password',          required: true,          placeholder: 'Enter password',        },        {        name: 'birthday',          label: 'Date of Birth',          type: 'date',          required: false,        },      ],    },    {      sectionTitle: 'Preferences',      fields: [        {          name: 'colorPreference',          label: 'Favorite Color',          type: 'color',          required: false,        },        {          name: 'experienceLevel',          label: 'Experience Level',          type: 'range',          min: 0,          max: 10,          step: 1,        required: false,        },        {          name: 'developmentSkills',          label: 'Development Skills',          type: 'select',          options: [            { label: 'Frontend', value: 'frontend' },            { label: 'Backend', value: 'backend' },            { label: 'Full Stack', value: 'fullstack' },            { label: 'Data Science', value: 'datascience' },          ],          required: true,        },      ],    },    {      sectionTitle: 'Feedback',      fields: [        {          name: 'websiteFeedback',          label: 'Your Feedback',          type: 'textarea',          required: false,          placeholder: 'Share your thoughts',        },        {          name: 'termsAgreement',          label: 'Agree to Terms',          type: 'checkbox',          required: true,        },        {          name: 'fileUpload',          label: 'Upload File',        type: 'file',          required: false,        },        {        name: 'searchQuery',          label: 'Search',          type: 'search',          required: false,          placeholder: 'Search...',        },      ],    },  ]; ---------------------------------------------------------------------- MarkMLl · 2024-10-03 07:04 My understanding from the devs is that creating a form involves Deep Magic which is beyond the reach of application programming. I don't know whether there is any other kind of container into which the description could be parsed and then built by invoking e.g. Lazbuild, but I think it would put you at the "bleeding edge". MarkMLl ---------------------------------------------------------------------- marcov · 2024-10-03 07:40 There is deep magic, but it is done, and that deep magic brought it within the realm of application programming.  Just very complicated, but it can be done.  People load Delphi forms from databases. Basically you need to parse the json, create classes as you go, and filling properties. Then you can lookup event handlers for them. I even seen people read script language code for the handler this way, and storing a pointer to the script language code in a .tag, and assigning a generic event handler that does some marshalling and then calls the script language code looked up from the tag. But it is all a lot of work, and you probably need to build a framework below it. And you can probably manually create hundreds of forms with the same effort. Lazarus, the LCL and the RTL is in source, you can sources. Particularly pay attention to  the classes unit https://www.freepascal.org/docs-html/rtl/classes/index-5.html  and then specially the read/writecomponent* and object*to* functions Some searching for components (delphi too!) that do something like this might help too. (*) modification notice: first edition said python, but it actually was Pascal script. Replace by more general "script"  moniker.