Since the subclasses can quite easy be entirely defined, as you'll see in a moment, before looking at their whole source code and logic it would be useful to refresh our memory of the skeletal structure for at least a couple of them. To begin with, let's show the code for the base class, as it was originally defined:
The above base class is really acting as the core structure for defining any further form element. It offers three common properties ($label, $name and $style) shared by any form element, being inherited in the derived subclasses. It also offers the "generateHTML()" method, which, as we'll see shortly, will take care of generating the proper HTML for each type of form object (text inputs, radio buttons, and so forth). Because each subclass is rather defined in a similar fashion, let's remember the basic definitions for the input text and the radio button objects, just to make sure that we're heading the right way for building the form generator. The basic code for the subclass tied to a text input element looked like this:
And, for radio buttons, the code was the following:
We're not going to list the basic code for each subclass tied to a form element again! That was already done in the previous article. However, demonstrating how they looked in their original incarnation is the perfect foundation for moving forward and seeing the complete code for each subclass. If you ever have worked with HTML forms (and who hasn't?), then you know that they offer numerous elements. It seems that the list for all of the subclasses is rather lengthy. If you don't take my word for it, take a look at the following section.
blog comments powered by Disqus |