ADD MORE EXAMPLE

## Add More Widget Example

<%perl> # Display the Contact info. $m->out(qq{Contact Info:
\n}); my $contacts = $user->get_contacts; $m->comp('/widgets/add_more/add_more.mc', type => 'contact', fields => [qw(type value)], name => 'contact', reset_key => $uid, objs => $contacts); # Display desks with an extra. $m->out(qq{Category Keywords:
\n}); my $desks = [ sort { $a->get_name cmp $b->get_name } $wf->allowed_desks ]; my $wid = $wf->get_head_desk_id; $rad->[0]{sub} = sub { $_[0]->{value} = $_[1] == $wid ? 1 : 0 }; # Call add_more to output the list of desks. $m->comp('/widgets/add_more/add_more.mc', type => 'desk', fields => [qw(name)], name => 'desk', extras => $rad, reset_key => $wfid, objs => $desks, incr => 1); # Display non-object data. Create the vals arguments. my $meths = { name => { disp => 'Name', props => { type => 'text', length => 35, maxlength => 76 } }, color => { disp => 'Color', props => { type => 'select', vals => { 1 => 'Red', 2 => 'Blue', 3 => 'Orange' } } } }; # Create the hashrefs of data. my $objs = [ { id => 1, name => 'Rose', color => 1 }, { id => 2, name => 'Violet', color => 2 } ]; # Now spit 'em out. $m->comp('/widgets/add_more/add_more.mc', type => 'flower', fields => [qw(name color)], name => 'flower', use_vals => 1, reset_key => $r->uri, objs => $objs, incr => 1, meths => $meths); $m->comp('/widgets/debug/debug.mc', %ARGS);
<%init>; my $uid = 2; my $user = Bric::Biz::Person::User->lookup({ id => $uid }); my $wfid = 1024; my $rad = [{ key => 'start_desk_id', disp => 'Start Desk', props => { type => 'single_rad'} }]; my $wf = Bric::Biz::Workflow->lookup({ id => $wfid }); <%doc> ############################################################################### =head1 NAME /widgets/add_more/index.html - Add More Widget Example =head1 VERSION $LastChangedRevision$ =head1 DATE $LastChangedDate: 2004-06-09 05:19:39 +0200 (Wed, 09 Jun 2004) $ =head1 DESCRIPTION This element demonstrates how to use the Add More Widget.