Including Forms in OOP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Including Forms in OOP

Post by jeffrydell »

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

Code: Select all

require_once('potter.class.php');
$potter = new Potter();
 
Within potter.class.php I have:

Code: Select all

   require_once('ZervWizard.class.php');
 
    class potter extends ZervWizard
    {
        function potter()
...
$this->wheel = 'round';
 
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:

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. -->
I need to do this:

Code: Select all

include('form.html');
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!
Last edited by jeffrydell on Sun Jan 20, 2008 1:04 pm, edited 2 times in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Including Forms in OOP

Post by Christopher »

You'd need to show us the actual code to see why you are getting a specific message. That Notice just means that the values had not been previously been set to a value when it was used.
(#10850)
jeffrydell
Forum Commoner
Posts: 77
Joined: Thu Jan 17, 2008 4:39 pm
Location: Menasha, WI

Re: Including Forms in OOP

Post by jeffrydell »

Done, I edited the original message.
Post Reply