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); %perl>