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/
/

_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to