Jump to content

Setup Array to define form elements to generate


dweeber

Recommended Posts

Been looking to see if anyone has published something like this.

 

I have a number of projects coming up which entail creating input form pages using PHP.  Some of these are quite large as to the number of entries, pages etc.. and the worst part is that I know in advance that they most likely will want to change/add to the form after I am done.

 

So rather than coding them physically in the code, I want to define the form elements in an array that I can store in a database/flat file and when the page loads, read from the array to construct the form output.

 

I don't have any issues with dealing with the database or even using arrays, but I have not been able to come up with an array setup that works.

 

Has anyone done this and would care to share the structure they used.

 

Everything that I find on the net is basically sites that want to host the form, but this will be in a non-Internet accessible site so that is not an option. 

Link to comment
Share on other sites

Hi

 

How simple will the form designs be?

 

I have written a small system that takes an XML file that defines the input elements and then puts out a series of pages each with those elements on it (final output to save the data was to another XML file).

 

With a limited number of questions per page this is fairly easy to do (doing a VB version of it was far more difficult). The structure including the entered data was just stored in an Object that was stored as a session variable, and once data input was complete it was processed.

 

However this does mean having small and fairly generic input forms.

 

All the best

 

Keith

Link to comment
Share on other sites

Off the top of my head:

 

Array
(
    [0] => Array
        (
            [display] => Username
            [params] => Array
                (
                    [type] => text
                    [name] => username
                    [id] => username
                )

        )

)

Link to comment
Share on other sites

...I have written a small system that takes an XML file that defines the input elements and then puts out a series of pages each with those elements on it (final output to save the data was to another XML file).

 

Keith,

 

Actually, had not really thought of XML for some reason.  The forms are pretty basic as they also have to be Accessible (ADA), but there will be sections and pages and required selection fields.  ....

 

Need to think about this a bit more.    Thanks for the reply.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.