Hey All,

A common theme we're running into is providing select boxes, and (radio|checkbox) groups with data stored in the database.

Select boxes seem to be pretty easy

package MyApp::Form::Element::Thingy;

use base qw( HTML::FormFu::Element::select );

sub new {
    my $self = shift->SUPER::new( @_ );

    my $c = $self->form->stash->{ context };
    my $thingies
        = $c->model( 'DB::Thingy' )->search( { foo => bar } );

    $self->options(
        [   {},
            map {
                    { label => $_->name, value => $_->id }
                } $thingies->all
        ]
    );

    return $self;
}

1;

Is this good idea? Is there a recommended way?

Creating a group of checkboxes and/or radio buttons from a db table seems to be a much harder problem -- is there a recommended solution for that as well?

-Brian

_______________________________________________
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