PHP XML Form Builder – Params

Update: The XML form builder is now live on the site, it can been seen here.

The decorator for the text form object has now been completed, the forms are drawn using divs, below is an outline of how a single form element is structured, as you can see there are three divs, each of which can have an independent class, style and id.

Form Element Structure

The updated XML structure for the text type is in the image below.

XML Structure
XML Structure

Although there are several elements for the text field, not all are mandatory, the builder informs you if any required information is missing.

In addition to being able to control every property in the XML file, you can also override the settings at runtime using any of the many public setting methods on the form builder. The following can all be overridden at runtime if required, element value, id, disabled setting, readonly setting, class and style, for each container div you can override the id, class and style.

The override methods are generally used to preset values (edit pages) and highlight elements after failed validation, I figured though that why limit it now, there was no harm in adding overrides for everything.

The original form builder required two XML files per form, one for form structure and another for the validation, the two will be combined in this version of the builder, once I have added all the types to the form builder I will start the validation system, as per params, the validation rules will be able to be set in the XML file and at runtime.

5 Replies to “PHP XML Form Builder – Params”

  1. Interesting that you decided to merge the validation with this, any particular reason for that? I remember one of the initial discussions we had where you decided to keep it seperate (one of those ones that I listened to rather than participated in, before I became more actively involved).

    My memory is a bit hazy as per usual, but I’m pretty sure you had a reason for keeping it seperate at the time, I just can’t recall what it was exactly (apart from readability).

  2. The original reason was speed, I didn’t want the processor to have to read in a large xml file when essentially it only cared about 3 elements for each field.

    I’ve since decided that the speed isn’t an issue because after all the use we have put the original version through, there have been no performance issues, that and in this version of the framework, the XML files are really only for the admin system, user facing forms will be created using the MySQL form builder.

    Having the two files together also means I can use the builder code to highlight the fields after input errors, rather than just change the element style now I can allow any number of properties to be altered.

  3. Thanks for the explanation, it makes sense.

    Do you foresee any such performance issues with the MySQL form builder? Or do you think that will process just as quickly, if not quicker? I’m not exactly au fait with PHP/MySQL speed concerns due to my lack of experience.

  4. Nope, I’m planning for the MySQL system to be quicker then the XML version.

    As I said before, there are going to be three form builders, XML, Array and MySQL.

    The XML form builder will be the slowest of the three systems for two simple reasons, one, the XML file has to be loaded on the fly and two the form builder validates the structure of the file, the Array and MySQL builder will not require as much structure validation, will be optional depending on where the data comes from.

    Forms built using the MySQL form builder will have the option of being output directly by the Array builder, essentially the data array will be cached in some way to simplify the select query, at present the table structure for the MySQL form builder is 14 tables.

Comments are closed.