SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    May 2006
    Location
    Austin
    Posts
    401
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Dynamic form generation / ordering

    I am trying to figure out how to create a dynamic form system.

    For example, take a simple contact form:

    Name:

    Email:

    Website:

    Comment:

    Let's say I want to be able to dynamically order, or remove form fields, based on a user's preferences.

    Email:

    Comment:

    Does anyone know of a good method of doing this? Obviously this isn't for a contact form. There are hundreds of possible fields, that should be able to be reordered or removed, etc. These fields can also exist in several categories that need to be segmented. The database tables do not need to be dynamic. There is a set number of fields, but I would like to be able to display only the user's needed fields in the order that they would like.

    My initial though is to create a table for field management, and then dynamically loop through the categories and then the field names, creating the entire form on the fly. The problem with this method, is that some fields are select lists, some are radio buttons, some input, etc...

    Any thoughts on something like this.
    Merchant Equipment Store - Merchant Services, POS, Equipment, and supplies.
    Merchant Account Blog | Ecommerce Blog

  2. #2
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    EDIT: Seems I didn't read your post thoroughly. The below post considers cases with dynamic record fields, not the case intended by the OP.

    Off Topic:

    EzPublish employs a database-driven system of classes, objects and their freely orderable and typed attributes for this purpose. Frankly I think it sucks very hard indeed and the concept itself has many nigh irreconcilable problems, but with quite a bit of thought it could perhaps be implemented tolerably.

    Another option, employed to some degree by Drupal if I'm not entirely mistaken, involves dynamic generation and modification of database tables, which has a whole host of issues as well – as you might well imagine.

  3. #3
    SitePoint Evangelist
    Join Date
    May 2006
    Location
    Austin
    Posts
    401
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I have access to a Propel generated yml or xml schema, so right now I'm leaning towards creating the form with this. I sort of hate to do this many steps to create a form.

    At a minimum:
    Read XML file ->
    Parse Table (s) we need to display ->
    Loop through categories and fields ->
    Display fields based on user's preferences / or don't display field

    My controllers are going to be memory hogs if I have to do this on every request...
    Merchant Equipment Store - Merchant Services, POS, Equipment, and supplies.
    Merchant Account Blog | Ecommerce Blog


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •