view release on metacpan or search on metacpan
lib/Gantry/Control/C/Groups.pm view on Meta::CPAN
label => $name,
type => 'checkbox',
default_value => 1,
checked => $groups{$user_id},
callback => $callback,
});
}
my $form = {
ajax_java_script => $ajax->define_javascript_functions,
legend => "Add/Remove Members",
back => $$self{location},
fields => \@fields
};
# stash form
$self->stash->view->form( $form );
} # end do_members
#-------------------------------------------------
lib/Gantry/Control/C/Groups.pm view on Meta::CPAN
#-------------------------------------------------
# _form( $row ? )
#-------------------------------------------------
sub _form {
my ( $self, $data ) = @_;
my $row = $data->{row};
my $form = {
legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
row => $row,
fields => [
{ name => 'name',
label => 'Group Name',
type => 'text',
is => 'varchar',
},
{ name => 'ident',
label => 'Ident',
type => 'text',
lib/Gantry/Control/C/Pages.pm view on Meta::CPAN
foreach ( $AUTH_USERS->retrieve_all(
{ order_by => 'last_name, first_name' } ) ) {
push( @owner_options, {
label => ( $_->last_name . ", " . $_->first_name ),
value => $_->id,
});
}
my $form = {
legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
width => "400",
label_width => '40px',
row => $row,
fields => [
{ name => 'uri',
label => 'URI',
type => 'text',
is => 'varchar'
},
{ name => 'title',
lib/Gantry/Control/C/Users.pm view on Meta::CPAN
},
{ optional => 1,
name => 'email',
is => 'varchar',
label => 'E-mail',
type => 'text',
}
);
my $form = {
legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
width => 400,
row => $row,
fields => \@fields
};
return( $form );
} # end _form
sub site_links {
lib/Gantry/Docs/Cookbook.pod view on Meta::CPAN
#-----------------------------------------------------------------
sub do_groups {
my ( $self, $user_id ) = @_;
my $threeway = Gantry::Utils::Threeway->new( {
self => $self,
primary_id => $user_id,
primary_table => 'user',
join_table => 'user_user_group',
secondary_table => 'user_group',
legend => 'Assign Groups to User'
} );
$threeway->process();
} # END do_groups
All you have to do is construct the three way object and call process
on it. This displays a form with a check box for each group. The current
memberships are already checked. Clicking in the boxes and submitting
the form updates them.
lib/Gantry/Docs/Cookbook.pod view on Meta::CPAN
The name of the controller's table.
=item join_table
The name of the joining table.
=item secondary_table
The name of the table on the other end of the many-to-many.
=item legend
HTML fieldset legend around the form where new joining table rows
are created from check box values.
=back
=head3 Using the three way manually
If you want to access rows from the table on the other end of the
many-to-many relationship, use the C<many_to_many> relationship in the model:
my @groups = $user->user_groups();
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
=for html <img src='http://www.usegantry.org/images/form.png' alt='Form Screen Shot' />
#-----------------------------------------------------------------
# $self->form( $row )
#-----------------------------------------------------------------
sub form {
return {
row => $row,
legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
fields => [
The default template is called C<form.tt>. Among other things, it expects
the return value hash to contain C<row> (if editing), C<legend> (legend
of form's fieldset), and C<fields> (what the user will see and enter or edit).
If the C<row> is supplied, its values are used for initial form population.
The C<legend> is set based on the C<path_info> which contains part of the
URL. If that URL fragment includes 'edit,' the legend is 'Edit.' Otherwise,
it is 'Add.'
The C<fields> are an array of the entry elements the user will see. The
order of the array controls the on screen order. Each field is a little
hash. While there are other keys, the four most common are used over and
over, not just in this example.
{
name => 'name',
optional => 0,
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
} # END do_main
#-----------------------------------------------------------------
# $self->form( $row )
#-----------------------------------------------------------------
sub form {
my ( $self, $row ) = @_;
return {
row => $row,
legend => $self->path_info =~ /edit/i ? 'Edit' : 'Add',
fields => [
{
name => 'name',
optional => 0,
label => 'Name',
type => 'text',
},
{
name => 'street',
optional => 1,
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
row_options Edit, Delete;
}
The main listing is just like the one for the address table, except for
the names of the displayed fields.
method form is AutoCRUD_form {
form_name birthday_form;
all_fields_but id;
extra_keys
legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`,
javascript => `$self->calendar_month_js( 'birthday_form' )`;
}
}
Now the name of the form becomes important. The calendar_month_js
method (mixed in by Gantry::Plugins::Calendar) generates the javascript
for the popup and its callback, which populates the date fields.
Note that we don't tell it which fields to handle. It will work on
all fields that have date_select_text statements.
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
page_link_label Address;
method do_main is main_listing {
cols name, street;
header_options Add;
row_options Edit, Delete;
title Address;
}
method form is AutoCRUD_form {
all_fields_but id, created, modified;
extra_keys
legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`;
}
}
table birth {
field id {
is int4, primary_key, auto;
}
field name {
is varchar;
label Name;
html_form_type text;
lib/Gantry/Docs/Tutorial.pod view on Meta::CPAN
method do_main is main_listing {
title `Birth Day`;
cols name, family, birthday;
header_options Add;
row_options Edit, Delete;
}
method form is AutoCRUD_form {
form_name birthday_form;
all_fields_but id;
extra_keys
legend => `$self->path_info =~ /edit/i ? 'Edit' : 'Add'`,
javascript => `$self->calendar_month_js( 'birthday_form' )`;
}
}
}
=head1 Summary
In this document we have seen how a simple Gantry app can be written
and deployed. While building a simple app with bigtop can take just
a few minutes, interesting parts can be fleshed out as needed. Our
lib/Gantry/Utils/Threeway.pm view on Meta::CPAN
my $gself = $self->{options}{self};
my $template = $self->{options}{template} || 'threeway.tt';
my $join_table = $self->{options}{join_table};
my $form_action = $self->{options}{action} || $gself->uri;
my $type = $self->{options}{type} || 'checkbox';
my $primary_table = $self->{options}{primary_table};
my $secondary_table = $self->{options}{secondary_table};
my $redirect_loc = $self->{options}{redirect_loc} || $gself->location;
my $order_by = $self->{options}{order_by} || 'id';
my $legend = $self->{options}{legend} || "Add ${secondary_table}s";
my $sch = $gself->get_schema();
my %param = $gself->get_param_hash;
# pull from the member table
my $selected = $sch->resultset( $join_table )->search(
{ $primary_table => $self->{options}{primary_id} }, { }
);
my %selected;
lib/Gantry/Utils/Threeway.pm view on Meta::CPAN
return;
}
my $available = $sch->resultset( $secondary_table )->search( {}, {
order_by => $order_by,
} );
$gself->stash->view->template( $template );
$gself->stash->view->form( {
legend => $legend,
action => $form_action
} );
$gself->stash->view->data( {
type => $type,
available => $available,
selected => \%selected
} );
} # END process
lib/Gantry/Utils/Threeway.pm view on Meta::CPAN
sub do_something {
my( $self, $blog_id ) = @_;
my $threeway = Gantry::Utils::Threeway->new( {
self => $self,
primary_id => $blog_id,
primary_table => 'blog',
join_table => 'blog_tag',
legend => 'Add Tags',
orderby => 'id',
secondary_table => 'tag'
} );
$threeway->process();
}
=head1 DESCRIPTION
lib/Gantry/Utils/Threeway.pm view on Meta::CPAN
Requires the following parameters
self # gantry site object
primary_id # the row id for which your adding the relationships to
primary_table # the primary table
join_table # the join table is where the relationship rows are stored
secondary_table # table in which your're relating to
Optional parameters
legend # form legend
order_by # sort list by this field
redirect_loc # redirect location for on submit or cancel
=item process()
preforms the CRUD like procedures for maintaining the three-way relationships.
=back
=head1 SEE ALSO
root/css/default.css view on Meta::CPAN
.block-rounded-genres h2 .trc { display: block; background: url(/images/trc-gray-block.gif) no-repeat 100% 0%; position: relative; padding: 3px 5px 2px 5px; margin-right: -1px; }
.block-rounded-genres .brc { background: url(/images/brc-gray-block.gif) no-repeat 100% 100%; position: relative; top: 2px; left: 1px; }
.block-rounded-genres .blc { background: url(/images/blc-gray-block.gif) no-repeat 0% 100%; position: relative; padding: 5px 5px 5px 10px; left: -2px; top: 0px; }
.block-rounded-genres .box_title h2 { line-height: 22px; background-color: #ddd; background-color: #afafaf; margin: 0px; color: #fff; text-align: center; }
#docs ul { list-style: none; padding: 0; margin: 0 }
#docs ul li { color: #333; }
#docs fieldset { background: #fff; padding: 0; margin: 0; border: none; }
#docs fieldset legend { display: none; border: none; font-size: 13pt; }
#download ul { list-style: none; padding: 0; margin: 0 }
#download ul li { float: left; width: 320px; height: 120px; text-align: center; vertical-align: bottom; }
#download fieldset { background: #fff; padding: 0; margin: 0; border: none; }
#download fieldset legend { display: none; border: none; font-size: 13pt; }
#features ul { list-style: none; padding: 0; margin-left: -8px; margin-right: -6px; }
#features ul li { font-size: 11pt; border-bottom: 1px dotted #666; padding: 5px; margin: 0; }
#dfeatures ul li { float: left; width: 320px; height: 20px; text-align: center; vertical-align: bottom; }
#features fieldset { background: #fff; padding: 0; margin: 0; border: none; }
#features fieldset legend { display: none; border: none; font-size: 13pt; }
root/css/gantry_forms.css view on Meta::CPAN
#comments li { }
#comment-form fieldset { background: transparent; border: none; }
#comment-form fieldset legend { display: none; }
#comment-form td { text-align: left; }
#comment-form td.rshd { text-align: right; }
dl.classlist { text-align: left; }
#body .classlist dl { text-align: left; }
#preview_button { position: relative; top: -60px; left: 130px; }
/* FORMS */
div.form-box { background: #FFF; padding: 0 2px 0 2px; width: 100%; }
div.form-box h5.heading { width: 100%; margin: 0 -2px 2px -2px; background: #AFAFAF; font-size: 1.3em; padding: 0 0 0 2px; }
root/css/gantry_forms.css view on Meta::CPAN
fieldset.missing { border: 1px dotted red; margin: -2px 0 0 0; }
ul.site-link-list { padding: 10px 0 0 10px; font-size: 11px; }
.actions { text-align: right; background: #AFAFAF; margin: 0 0px 0px 0px; font-size: 1.3em; padding: 0 0 0 2px; }
input { font-size: 10px; border: 1px solid #777; background: #dce2da; }
select { font-size: 10px; border: 1px solid #777; background: #dce2da; }
textarea { border: 1px solid #777; background: #dce2da; font-family: 'Lucida Grande', helvetica, arial, sans-serif; font-size: 1.0em; }
fieldset { background: #fff; border: 1px solid #c7c7c7; padding: 10px; }
legend { padding: 0 10px 0 10px; border: 1px solid #c7c7c7; background: #fff; }
.results-box { clear: both; border: 1px solid #777; font-size: 10px; }
.results-box table { padding: 0; margin: 0; background: #eee; width: 100%; }
.results-box table td { padding: 0 4px 0 4px; margin: 0; border: 0; }
.results-box table tr.heading { background: #afafaf; }
.results-box table tr { background: #fff; }
.results-box table tr .rhdr { text-align: right; }
.results-box table tr .rdta { text-align: right; font-size: 10px; }
.results-box table tr.alt td { background: #ecf6fc; }
root/css/gantry_site.css view on Meta::CPAN
h1 { font-size: 2.4em;}
h2 { font-size: 2.2em;}
h3 { font-size: 2.0em;}
h4 { font-size: 1.8em;}
h5 { font-size: 1.6em;}
h6 { font-size: 1.4em;}
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: #3A566B; text-decoration: none;}
p { margin: .3em 0 1em 0; font-family: 'Lucida Grande', helvetica, arial, sans-serif; font-size: 1.0em; line-height: 1.5em; color: #333;}
ul { margin: 1em 0;}
legend, li, dt, dd, th, td { font-family: 'Lucida Grande', helvetica, arial, sans-serif; font-size: 1.0em; line-height: 1.5em; color: #333;}
dd { font-size: 1em;}
a { color: #3A566B; text-decoration: none;}
a:hover { text-decoration: underline;}
em { color: #3A566B;}
.currency { text-align: right; }
/* Logo-------------------------------------------------------------------------------- */
#header h1 { position: absolute; margin: 0; top: 69px; left: 0; width: 17em; height: 7.2em; overflow: hidden; clip: rect(0 17em 7.2em 0);}
#header h1 a { display: block; padding-top: 17em; /* background: transparent url(../images/merchspot.gif) top left no-repeat; */ }
root/form.tt view on Meta::CPAN
view.form - a hash with these keys:
method - POST or GET (defaults to POST)
action - url of page to process form (defaults to self.uri)
name - the name of the form (useful for javascript references)
row - the current row object from the table (if available)
javascript - javascript code the form needs (like for date popups.
Consider using Gantry::Plugins::Calendar and calling
its calendar_month_js.
(This could actually be anything, it just gets copied to
the output immediately after the form opening tag)
legend - The title for the legend box wrapping the form.
change_log - An array of change_log entries (optional). Each entry
is a hash with these keys:
date - the date the change happened
by - the name of the person making the change
message - what happened
results - the return value from Data::FormValidator->check
cellspacing - becomes the cellspacing parameter of the form's table
(defaults to 0)
width - becomes the width parameter of the form's table
root/form.tt view on Meta::CPAN
<form
method="[% view.form.method || 'post' %]"
action="[% view.form.action || self.uri %]"
name="[% view.form.name %]"
[% IF view.form.enctype != ''; "enctype='$view.form.enctype'"; END; %]
>
[% view.form.javascript %]
<fieldset>
<legend>
[% view.form.legend %]
</legend>
[%- IF view.form.change_log %]
<div style="float: right; width: 240px">
<fieldset>
<legend><a href='[% view.form.change_log_url %]'>Change Log</a>
</legend>
<div id="change_log">
[% FOREACH entry IN view.form.change_log %]
<b>[% entry.date %]</b> By [% entry.by %]<br />
· [% entry.message %]<br />
[% END %]
</div>
</fieldset>
</div>
[%- END %]
root/form_ajax.tt view on Meta::CPAN
[% title = view.title %]
[% view.form.ajax_java_script %]
<fieldset>
<legend>
[% view.form.legend %]
</legend>
<div id="float_left">
<table class="results" cellspacing="[% view.form.cellspacing || 0 %]"
border=0 width="[% view.form.width %]">
[% FOREACH field IN view.form.fields %]
<tr class="[% 'selected' IF field.checked %]">
<td class="shd" style="width: [% field.label_width || '20%' %]">
[% field.label %]
</td>
<td class="dta" style="width: [% field.width || '80%' %]" valign="top">
root/login.tt view on Meta::CPAN
[% title = view.title %]
<style type="text/css">
#login_page { width: 600px; }
#login { float: left;}
#login ul { list-style: none }
#login input { border: 1px solid #c7c7c7; }
#login fieldset legend { padding: 3px }
#login fieldset { width: 150px; border: 1px solid #c7c7c7; padding: 10px 0px 15px 15px;}
#login_page #login_text { float: left; width: 300px; }
</style>
<div id="login_page">
<div id="login">
<fieldset>
<legend>Login</legend>
[% IF site.stash.controller.data.errors > 0 %]
<div id="login_errors">
<ul>
[% FOREACH err IN site.stash.controller.data.errors %]
<li>[% err %]</li>
[% END %]
</ul>
root/moxie/delete.tt view on Meta::CPAN
[% title = view.title %]
<form method='post' action='[% site.uri %]/yes' class='form-box' >
<div class="form-box">
<h5 class="heading">[% view.form.legend || 'Delete' %]</h5>
<dl><dd>[% view.form.message %]</dd></dl>
</div>
<div class="form-box actions">
<input type="submit" name="submit" value="Continue with Delete" />
<input type="submit" name="cancel" value="Cancel" />
</div>
</form>
root/moxie/form.tt view on Meta::CPAN
) %]
[%- IF view.form.show_error_summary %]
[% PROCESS error_summary %]
[%- END %]
[%# check for older style crud form %]
[%- IF view.form.fields %]
<div class="form-box">
<h5 class="heading">[% view.form.legend %]</h5>
<p class="form-description">
[% view.title %]
</p>
[%- FOREACH field_data IN view.form.fields %]
[%- PROCESS field
dta = field_data
row = view.form.row
layout = 'default' %]
[%- END %]
</div>
[%- ELSE %]
[%- WHILE ( row = view.form.row.next ) %]
<div class="form-box">
<h5 class="heading">[% view.form.legend %]</h5>
[%- FOREACH field_data IN view.form.fields %]
[%- PROCESS field
dta = field_data
row = row
layout = 'default' %]
[%- END %]
</div>
[%- END %]
root/moxie/form_onetomany.tt view on Meta::CPAN
[%- USE form = HTML.SuperForm( self.params ) %]
<div class="results-box">
<table class="results" id="results">
<tr class="heading">
<td colspan="2" class="hdr">
[% view.form.legend %]
</td>
</tr>
[% FOREACH field IN view.form.fields %]
[% onclick_text = BLOCK -%]
javascript: ajax_action('[% field.cb_action %]', this.checked, 'view_[% field.name %]' );
[%- END %]
<tr class="[% 'selected' IF field.checked %]">
<td class="form_selector">
root/moxie/threeway.tt view on Meta::CPAN
field[i].checked = false ;
}
}
// End -->
</script>
<form method="post" action="[% view.form.action || self.uri %]"
id="[% view.form.name || 'myform' %]">
<div class="form-box">
<h5 class="heading">[% view.form.legend || 'Make Selection' %]</h5>
<dl class="checklist">
[% IF view.data.type == 'checkbox' %]
[%- WHILE ( available = view.data.available.next ) %]
[%- id = available.id %]
<dd>
<input type="checkbox" value="1" name="subscribe:[% id %]"
[%- IF view.data.selected.$id %]
checked="checked"
[%- END %] />
root/sample_wrapper.tt view on Meta::CPAN
#users { width: 150px; margin: 0 0 10px 0;}
#user_content ul { list-style: none; margin: 0; padding: 0;}
#products ul { list-style: none; margin: 0; padding: 0;}
#product_attribs ul { list-style: none; margin: 0; padding: 0;}
#login_errors ul { padding: 0 0 0 0; }
#login_errors { white-space: nowrap; }
#users ul { list-style: none; margin: 0; padding: 0;}
#site_links { visibility: hidden;}
#footer #site_links { visibility: visible;}
fieldset { background: #e9e9e9; border: 1px solid #c7c7c7;}
legend { padding: 0 10px 0 10px; border: 1px solid #c7c7c7; background: #fff;}
#content .box table { padding: 0; margin: 0; background: #eee; width: 100%;}
#content .box table td { padding: 0 4px 0 4px; margin: 0; border: 0;}
#content .box table tr { background: #b9c5b4;}
#content .box table tr + tr { background: #fff;}
#content table .rhdr { text-align: right }
#content table .rdta { text-align: right }
#content table .rshd { text-align: right }
#footer { font: normal 12px/20px sans-serif; text-align: center; padding: 10px; margin: 0px auto ; width: 740px;}
#float_right { float: right;}
#float_left { float: left;}
root/search.tt view on Meta::CPAN
<form
method="[% view.form.method || 'post' %]"
action="[% view.form.action || self.uri %]"
name="[% view.form.name %]"
>
[% view.form.javascript %]
<fieldset>
<legend>
[% view.form.legend %]
</legend>
<div style="float: left">
<table class="results"
cellspacing="[% view.form.cellspacing || 0 %]"
border="0"
width="[% view.form.width %]">
[% FOREACH field IN view.form.fields %]
root/sfbb/form.tt view on Meta::CPAN
[%- END %]
[%# check for older style crud form %]
[%- IF view.form.fields %]
<div class="form-box [% view.form.class %]">
[% UNLESS view.form.nohead %]<h4 class="heading">[% view.title %]</h4>[% END %]
[%-
fieldsets = [];
cfsgroup.legend = 'gantry-default';
cfsgroup.fields = [];
FOREACH field_data IN view.form.fields;
IF field_data.fieldset && ! field_data.fieldset.match(cfsgroup.legend);
IF cfsgroup.fields.size;
fieldsets.push(cfsgroup);
cfsgroup = {};
cfsgroup.fields = [];
ELSE;
cfsgroup = {};
cfsgroup.fields = [];
END;
cfsgroup.legend = field_data.fieldset;
cfsgroup.fields.push(field_data);
ELSE;
cfsgroup.fields.push(field_data);
END;
END;
fieldsets.push(cfsgroup);
-%]
[%- FOREACH fieldset IN fieldsets %]
<fieldset class="[% fieldset.legend | replace('\s+', '-') | replace("'", '') | lower %]">
[% UNLESS fieldset.legend.match('gantry-default') %]
<legend>[% fieldset.legend %]</legend>
[% END %]
[% FOREACH field_data IN fieldset.fields; %]
[%- PROCESS field
dta = field_data
row = view.form.row
layout = 'default' %]
<br id="[% field_data.name _ '_br' %]" style="clear: both" />
[% END %]
</fieldset>
[%- END %]
</div>
[%- ELSE %]
[%- WHILE ( row = view.form.row.next ) %]
<div class="form-box [% view.form.class %]">
<h5 class="heading">[% view.form.legend %]</h5>
[%- FOREACH field_data IN view.form.fields %]
[%- PROCESS field
dta = field_data
row = row
layout = 'default' %]
[%- END %]
</div>
[%- END %]
root/threeway.tt view on Meta::CPAN
field[i].checked = false ;
}
}
// End -->
</script>
<form method="post" action="[% view.form.action || self.uri %]"
id="[% view.form.name || 'myform' %]">
<fieldset>
<legend>
[% view.form.legend %]
</legend>
<dl class="checklist">
[% IF view.data.type == 'checkbox' %]
[%- WHILE ( available = view.data.available.next ) %]
[%- id = available.id %]
<dd>
<input type="checkbox" value="1" name="subscribe:[% id %]"
[%- IF view.data.selected.$id %]
checked="checked"
[%- END %] />