Including Forms in OOP
Posted: Sun Jan 20, 2008 12:20 pm
I'm working with the ZervWizard class as a beginning OOP learning experience. I'm a hands-on 'learn-by-experiences' guy whose eyes glaze over when I'm reading a book that has theory, or even practical examples. I have to DO to make anything stick.
ZervWizard is a class for handling multi-page forms, loads & validates values, and controls all the navigation between pages. Exactly the missing piece of the puzzle which I was needing.
The example script instantiates a class which extends the ZervWizard class. In the example, all the HTML is a part of the initial calling script. That's fine when you are only working with three pages and there are just a few fields per page ... my application has 13 forms (steps) with dynamic selection of forms and some event-specific forms that get plugged in on the fly. NOT AT ALL practical to think I can put everything in the calling script, or even contain those forms within functions that are included prior to instantiating the class.
I tried to substitute an include(form.html) statement rather than having the code in the actual 'calling' script. The forms all need default values and when I refer to those values, I get Notice: Undefined property: referring to whatever I needed.
EXAMPLE
Script Name = Harry.php
In that script I have
Within potter.class.php I have:
Now, we go back to Harry.php for the html to put a form on the screen.
The example would do this RIGHT WITHIN HARRY.PHP:
I need to do this:
because the forms are too big, and too complex to just 'hard code' in a single script. But when I do, the reponse I get is Notice: Undefined property: potter::wheel
Any thoughts on either why I can't 'see' the variables (even if I refer to them as class->name) OR what I can do to access the forms differently?
Thanks for whatever help you can offer!
ZervWizard is a class for handling multi-page forms, loads & validates values, and controls all the navigation between pages. Exactly the missing piece of the puzzle which I was needing.
The example script instantiates a class which extends the ZervWizard class. In the example, all the HTML is a part of the initial calling script. That's fine when you are only working with three pages and there are just a few fields per page ... my application has 13 forms (steps) with dynamic selection of forms and some event-specific forms that get plugged in on the fly. NOT AT ALL practical to think I can put everything in the calling script, or even contain those forms within functions that are included prior to instantiating the class.
I tried to substitute an include(form.html) statement rather than having the code in the actual 'calling' script. The forms all need default values and when I refer to those values, I get Notice: Undefined property: referring to whatever I needed.
EXAMPLE
Script Name = Harry.php
In that script I have
Code: Select all
require_once('potter.class.php');
$potter = new Potter();
Code: Select all
require_once('ZervWizard.class.php');
class potter extends ZervWizard
{
function potter()
...
$this->wheel = 'round';
The example would do this RIGHT WITHIN HARRY.PHP:
Code: Select all
<html>Say stuff / get stuff</html>
<!-- No problem referencing value="<?=$potter->wheel ?>" here and getting 'round' as teh default value for that field. -->Code: Select all
include('form.html');Any thoughts on either why I can't 'see' the variables (even if I refer to them as class->name) OR what I can do to access the forms differently?
Thanks for whatever help you can offer!