

PHP ships with the DOMDocument class (and all of its derivatives. But HTML is not just any string: there's grammar and rules involved. A class should have only 1 job, and yours does. More to come, because there are a lot of things that need addressing, outside of these primary issues. Ajax implies JS, which in turn implies using meaningful selectors: I can't set ID's here, though. If things do go worng, it'll probably result in malformed markup, and the source of the problem will be hard to track. Stringing together markup is tedious, horrible to debug, and equally pointless to test.The buildForm is a one-shot deal: it returns an HTML string, that is, to all intents and purposes, static. buildField is public, but contrary to what I'd assume, it is incapable of adding fields to the form.Yes, there are, apart from those mentioned above, some other omissions/flaws: Programming by array is not the way to go. You can't handle nested forms, validators and to use this code, you need to know what type of array this class expects. If by efficient, however you mean: portable, easy to use (as in clear API), robust and flexible then no.

Not as fast as non OO code, but faster than most form builders out there.

If by that, you mean: is it fast, then yes, it probably is. I'll be expanding on each of the issues through updates:ĭefine efficient. Right, a short and simple answer to each of your questions, for now. Please make sure that you have set the field properties correctly." Įxample: $formBuilder = new FormBuilder() Public function buildField($field, $type, $name, $placeholder = null, $style = null, $options = null, $value = null) Is this using the concepts in the proper way?įor($i = 0 $i buildField($fields,Įmpty($fields) ? '' : $fields,Įmpty($fields) ? '' : $friends.I want to know about the following topics:
PHP WEB FORM BUILDER GENERATOR
I would like my form generator class to be reviewed.
