clControlMaker that inherits from clFormMaker:
Expand|Select|Wrap|Line Numbers
- use strict;
- use clFormMaker;
- package clFormMaker::clControlMaker;
- our @ISA = qw(clFormMaker);
- sub new
- {
- #constructor
- my ($class_name) = @_;
- my ($self) = clFormMaker->new(@_);
- bless ($self, $class_name);
- return $self;
- }
Expand|Select|Wrap|Line Numbers
- use strict;
- use clValidate;
- package clValidate::clFormMaker;
- our @ISA = qw(clValidate);
- sub new
- {
- #constructor
- my ($class_name, $full_class_name, $name, $action, $method, $enctype, $ref) = @_;
- my ($self) = clValidate->new(@_); #THIS CAUSES PROBLEMS
- bless ($self, $class_name);
- .
- .
- .
- return $self;
- }
Expand|Select|Wrap|Line Numbers
- use strict;
- package clValidate;
- sub new
- {
- #constructor
- my ($class_name) = @_;
- my ($self) = {};
- bless ($self, $class_name);
- #props
- return $self;
- }
Expand|Select|Wrap|Line Numbers
- my $control = clFormMaker::clControlMaker->new('formname', 'polymorphism.pl', 'POST',
- 'application/x-www-form-urlencoded', $ref);
- $control->set('_issticky', 1);
- $control->makeform();
- print $control->maketextbox('text1', 'width: 200px;', 'number');
The problem I'm having is that it doesn't work - when I use the same code to make clFormMaker inherit from clValidate as clControlMaker inherits from clFormMaker I get an error -
"Can't locate method 'new' via package clFormMaker".
I think I am on the right lines but as one class inherits another class that itself inherits, there's something I'm missing.
Phew. Hope that's clear enough. It's a bit frustrating to say the least. This is all a lot easier in php!
Cheers
Richard