[html-formfu] How to make checkbox (checked/unchecked) database
driven
kewei xiao
kewei.xiao at nald.ca
Thu Jul 5 19:27:28 GMT 2007
Now I set up the 'default' to be checked. Is it a way to make it
unchecked according to a certain condition? In my case the condition
will be the non-administrator users' checkbox will be un-checked:
/use strict;
use warnings;
use base qw( HTML::FormFu::Element::multi );
__PACKAGE__->mk_accessors(qw( group_type ));
sub render {
my $self = shift;
my $type = $self->group_type;
$self->attributes( { class => $type . 'group' } );
my $c = $self->form->stash->{ context };
my $roles = $c->model( 'Links::AccountRole' )->search;
$self->elements( [ map {
{ type => $type, name=>'role', value=> $_->id, label =>
$_->name, checked=>'checked' }
} $roles->all ] );
return $self->SUPER::render( @_ );
}
1;
/Kewei/
/
More information about the HTML-FormFu
mailing list