CatalystX-CRUD-YUI
view release on metacpan or search on metacpan
lib/CatalystX/CRUD/YUI/TT/crud/form.tt view on Meta::CPAN
<table class="crud">
[% FOREACH fname = fields.order;
field = form.field( fname );
# make sure any serial (autoincrem) fields
# are skipped. This is a backwards compat fix
# since RDG used to generate a hidden serial
# field for autoincrem PKs
IF (field.class == 'serial' || field.isa('Rose::HTMLx::Form::Field::Serial'));
NEXT;
END;
# set DateTime format
IF field.isa('Rose::HTML::Form::Field::DateTime');
IF (field.internal_value.epoch.defined);
CALL field.output_format( yui.serializer.datetime_format );
END;
END;
# prevent <enter> key in text fields from submitting form prematurely.
IF field.isa('Rose::HTML::Form::Field::Text');
IF(!field.onkeypress);
CALL field.onkeypress("return YAHOO.crud.check_return_key(event)");
END;
END;
%]
<tr class="[% (loop.count % 2) ? 'alternate' : '' %]">
[% IF (field.description.defined && field.description.text.length) %]
<tr><th colspan="2"><div class="description">
The <strong>[% field.name %]</strong> field specifies [% field.description %].
</div></th></tr>
[% END %]
[%
# read-only fields
# check these first as this is not a field attribute
IF (fields.readonly.defined( fname ));
thopen; field.xhtml_label; thclose;
tdopen;
"<div class='input'>";
IF field.isa('Rose::HTML::Form::Field::TextArea');
# if there is raw html in the field, assume it
# handles it's own line breaks, etc.
UNLESS field.output_value.match('<.+>');
"<pre>";
field.output_value | Autoformat | html;
"</pre>";
ELSE;
field.output_value;
END;
ELSIF field.isa('Rose::HTML::Form::Field::DateTime');
IF (field.internal_value.epoch.defined);
field.output_value _ '';
END;
ELSIF field.isa('Rose::HTMLx::Form::Field::Boolean');
field.output_value == '1' ? 'true' : 'false';
ELSIF field.isa('Rose::HTML::Form::Field::PopUpMenu');
field.value_label;
ELSE;
form.field_value( fname );
END;
PROCESS crud/related_field_link.tt;
"</div>";
# optionally pass the readonly value through hidden
# as when creating an object with a FK that is readonly.
# this only works with values that are not objects themselves.
IF (fields.readonly.item( fname ) > 1)
%]
<input type="hidden" name="[% fname %]" value="[% field.output_value %]" />
[%
END;
tdclose;
# autocomplete magic
ELSIF (field.can('autocomplete'));
u = field.url;
USE url = url( u.0, u.1 );
SET input = {
label = field.xhtml_label,
url = u.0,
params = url.match('\?(.+)$').0.replace('&','&'),
id = 'ac_' _ fname, # fname will be used as hidden field name
hidden_value = field.internal_value,
fname = fname,
param = u.1,
limit = field.limit,
cache_size = 50,
csize = field.size || 0,
tabindex = field.tabindex,
};
# if searching, we do not have an object yet.
IF (object);
input.value =
form.metadata.foreign_field_value( fname, object )
||
field.internal_value;
END;
PROCESS crud/autocomplete_field.tt;
# checkboxes
ELSIF (field.can('xhtml_checkbox'));
thopen; field.xhtml_label; thclose;
tdopen; field.xhtml_checkbox; tdclose;
# hidden fields
ELSIF (field.isa('Rose::HTML::Form::Field::Hidden'));
IF show_hidden_fields;
t = form.hidden_to_text_field(field);
thopen;
t.xhtml_label;
thclose;
tdopen;
t.xhtml;
( run in 2.612 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )