Gantry
view release on metacpan or search on metacpan
root/sfbb/form.tt view on Meta::CPAN
[%-
# This form template is used by Sunflower Broadband and is subject
# to changes that may not be backwards compatible. Use at your own risk.
# This template supports all the field properties in the default form.tt
# template and additionally supports the following properties.
# fieldset - If fields have a fieldset property specified the template
# will group the fields together into a fieldset.
-%]
[%- USE form = HTML.SuperForm( self.params ) %]
[%- form.start_form(
action => ( view.form.action || self.uri ),
enctype => view.form.enctype,
class => ( view.form.class || 'form-box' ),
method => ( view.data.method || 'post' )
) %]
[%- IF view.form.show_error_summary %]
[% PROCESS error_summary %]
[%- 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 %]
[%- END %]
<div class="form-box [% view.form.class %] actions">
[%- UNLESS view.form.no_submit %]
[% form.submit(
id => 'submit',
name => 'submit',
default => ( view.form.submit_button_label || 'Submit' ),
label => ( view.form.submit_button_label || 'Submit' )
) -%]
[%- END %]
[%- IF view.form.submit_and_add_another %]
[%- form.submit(
name => 'submit_add_another',
default => ( view.form.submit_and_add_another_label
|| 'Submit & Add Another' ),
label => ( view.form.submit_and_add_another_label
|| 'Submit & Add Another' )
) %]
[%- END %]
[%- UNLESS view.form.no_cancel %]
[%- form.submit(
id => 'cancel',
name => 'cancel',
default => ( view.form.cancel_button_label || 'Cancel' )
label => ( view.form.cancel_button_label || 'Cancel' )
) -%]
[%- END %]
</div>
[% form.end_form %]
[% BLOCK field %]
[%- type = dta.type %]
[%- name = dta.name %]
[%- missing = view.form.results.missing( "$name" ) %]
[%- required = dta.optional ? 0 : 1 %]
[%- required_mark = required ? ' *' : '' %]
[%- IF type == 'file' %]
<label id="[% dta.name _ '_label' %]" class="[% required ? 'required' : '' %]"
for="[% dta.name %]">[% dta.label _ required_mark %]</label>
<input type="file" name="[% dta.name %]" />
[%- PROCESS row_status
invalid = view.form.results.invalid( "$name" ).join( ',' )
missing = view.form.results.missing( "$name" )
hint = dta.hint
name = dta.name
( run in 0.741 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )