Dynamic Elements Processor with PHP 5

Building forms and elements for websites sometimes means a lot of work, specially if you create bigger websites. Luckily there a some great tools like QuickForm from PEAR which is very powerfull, but asks to install the PEAR environment. Well this application asks only for three class files and is quiet easy to implement (see screenshots below). This application makes use of the RecursiveArrayIterator from PHP 5 and an Element Iterator to loop through all parts of the elements. Among other features you'll find submit, select, text, textarea, radio and other elements, which have not to be related to forms - such as the Span, Div or Table element (in total 17). If you make usage of the Dynamic Elements Processor you need only two three lines to create an element: The name of the element, the options and the append part of the script. Hint: If you use several elements one behind the other with empty options, the option element may not be removed. That's all there is to consider.

The scripts snippets you see here (the complete script is downloadable) is only a small part of the complete application. That's it. All stuff is all prepared for your convenience (example and class-files included). Best regards Claudio Biesele

Part of the Elements Creation Code :



Part of the ProcessElements Class Code:

public function createFormStart($formdata) {
  $this->formdata = $formdata;
      while(list($this->key, $this->val) = each($this->formdata)) {
      echo "<form action=\"{$this->val[0]}\" method=\"{$this->val[1]}\" name=\"{$this->val[2]}\" enctype=\"{$this->val[3]}\" {$this->val[4]}>";

Picture element_1.jpg
16 Examples: To create the necessary code you need only two,three lines per element.
Picture element_2.jpg
Dynamic created form: With Dynamic Elements Processor loading takes only a fraction of a second.
Download the full script at www.fastproject.ch. The downloaded script is free from Copyright restrictions, Zurich, 24th of November 2009.
Donate with PayPal: