The first step you will need to do is design the tables properly, so basically you need to know how to design table to support dynamic fields and the field will be able to validate/handle such such data.
What I did with my application(dynamic application where the UI fields can be configured in the application's admin) is saving the configuration in the database, each time there is a transaction, the page will fetch the configuration for the selected biller and it will generate the required fields. and when the form is submitted, the application will again fetch the configuration and make validation based on the setting in client_field
Account table *Contain information such as account
- account_id //primary key of this table
- account_name
- account_status
Client table
- client_id //primary key of this table
- account_id //foreign key:account table
- client_name
- client_status
you can add different column for the client depending on your requirement, but make sure not to add the required UI fields in this table, instead create the table like below
client_field table //will contain table that can be defined/configured
- field_id //primary key of this table
- client_id //foreign key:client table
- field_name //the field name that will appear in the user interface
- field_title //appear when on mouseover on the field
- field_datatype //this can be text,integer,date,boolean,etc
- field_type //field input type: this can be a textbox,datepicker,dropdown list,etc
- field_required //flag to indicate whether the field is required
- field_display //flag to indicate whether the field will appear/hidden in the user interface
- field_defaultvalue //default value to set when the page renders
- field_minvalue //minimum value the field will accept: only acceptable when dataytpe is integer/double
- field_maxvalue //same as field_minvalue description instead it will check the maximum integer/double value
- field_maxlength //max length for the field
- field_order //order of the field in the interface
- field status //activate or deactivate the field
You can add additional column but you need to make sure it will be fluid and not redundant.
let us say, you have field_type dropdown list, you need to create another table, lets call it
field_dropdown
- id //primary key for this table
- field_id //foreign key from client_field
- dropdown_value //the value that will be used in the dropdown list when selected
- dropdown_description //the description that will appear in the dropdown list
- dropdown_order //order of the item
- dropdown_status //flag whether this record is active/inactive
You might be wondering how to save the data if this is the case, the data must be saved in another table, lets call it
client_information
- id //primary key for this table:
- client_id //foreign key from the client table
- field_id //foreign key from client_table.
- value //the value from the user interface
this way, when you save a new client, each field in the client_field will add a new row in the client_information table along with the value inserted by the user
the challenges in designing this kind of application are:
- it is quite hard to develop (lots of condition and mapping, and require alot of time)
- you will need to properly configure the fields in order for it to properly work
- proper system design,architecture, and flow otherwise it will ruin the dynamicity of the system
- you will need proper documentation so that you will understand which is which.
- the process will be linear for all the clients except if you can alter your own flow by saving them into the database
the PROS for this design is:
- once it is finished, you do not require anymore developer to add additional code except for software enhancement such as feature that is not supported when it was released.
- the application will be dynamic and adding any field will be easy and maintainable via the admin module
I am not saying this is the MUST DO, but this is my suggestion on how to develop application that requires dynamic data fields, and so far from my experience in developing one, it did work well just as long it is well design and developed.