I'm trying to subclass the Select element and be able to change which
options are added via a variable (user_type) in the form config. The
variable (user_type) isn't being initialized when _populate_options is
called. How should I be doing this? Here is the code:
package Tsunami::HTML::FormFu::Element::UserSelect;
use base 'HTML::FormFu::Element::Select';
use Class::C3;
use SessionInfo;
__PACKAGE__->mk_item_accessors( qw( user_type ) );
sub new {
my $self = shift->next::method(@_);
$self->_populate_options;
return $self;
}
sub _populate_options {
my $self = shift;
my $schema = $SessionInfo->schema;
warn $self->user_type;
my @users =
$schema->resultset('User')->active_users
->search(undef, { 'order_by' => 'me.lastname asc' });
$self->options( [
{ value => '', label => 'All' },
map { { value => $_->userid, label => $_->lastname . ', ' .
$_->firstname } }
@users
] );
}
1;
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu