Hi All,

I am trying to work with the CGI::FormBuilder module in a Catalyst
environment. My question is more about OO programming than either of those 2
modules though.

I am trying to create a method/sub that will create a form to either edit or
add an entry. I am creating the initial object and depending on whether or
not the entry already exists, I want to set-up some aspects of my object
(making sense??). So I want to create the object, assign it to a variable
and make changes to it (or not) later depending on some condition. Here's an
abridged version of what I have done so far:

use strict;
use warnings;
...snip

sub edit : Local Form {
  my ($self, $c, $id) = @_;

# Here comes my form
my $fb = $self->formbuilder->field(
                name  => 'Users',
                type => 'select',
                options =>
                        [ map { [ $_ -> id, $_->code ] }
$c->model('Files::users')->all ],
                required => 1,
               #value => undef
        );
...
  if ($id) {
      $fb->{value} = $some_default_val;
  }
}


So I guess the question is what sort of structure have I created initially
with $fb and $self and does $fb->{value} make sense. Can I add an attribute
to an object after I've created it in this way.

I hope that makes sense. I am almost confusing myself here :-)
Thanx.
Dp.

Reply via email to