%#-- Begin HTML --#
<& '/widgets/wrappers/sharky/header.mc',
   title => "$disp Profile",
   context => "Admin | Profile | $disp | $crumb"
&>
<form method="post" action="<% $r->uri %>" name="field_type_profile"
      onsubmit="return confirmChanges(this)">
<%perl>;
my $num = 0;

$m->comp('/widgets/profile/hidden.mc',
         'name' => 'field_type_id',
         'value' => $id)
  if defined $id;

# PROPERTIES
$m->comp('/widgets/wrappers/sharky/table_top.mc',
         'caption' => 'Properties',
         'number' => ++$num);
$m->comp('/widgets/profile/text.mc', 'disp' => 'Key Name',
         'value' => $field->get_key_name(), 'readOnly' => 1);
$m->comp('/widgets/profile/dumpRemainingFields.mc', 'objref' => $field,
         'readOnly' => $no_edit, 'fieldsUsed' => $exclude);
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');

# META DATA
$m->comp('/widgets/profile/hidden.mc', 'name' => 'type', 'value' => $which);
$m->comp('/widgets/wrappers/sharky/table_top.mc',
         'caption' => 'Display Attributes',
         'number' => ++$num);
$m->comp("/widgets/$type/$type.mc", field => $field);
$m->comp('/widgets/wrappers/sharky/table_bottom.mc');

$m->comp('/widgets/profile/formButtons.mc',
	 type => $type,
         widget => $type,
	 section => $section,
	 no_del => $no_del,
	 val => defined $id ? undef : 'next_dkgreen',
	 no_save => $no_edit);
</%perl>
</form>
<& '/widgets/wrappers/sharky/footer.mc', 'param' => \%ARGS &>
%#-- End HTML --#

<%once>;
my $class = 'Bric::Biz::ElementType::Parts::FieldType';
my $section = 'admin';
my $type = 'field_type';
my $disp = get_disp_name($type);
</%once>

<%args>
$id => undef
</%args>

<%init>;
# Instantiate an object.
my $field = $ARGS{obj}
  ? $ARGS{obj}
  : defined($id)
      ? $class->lookup({'id' => $id})
      # This part isn't really necessary, since no new fields are ever created
      # here.
      : $class->new();
$id ||= $field->get_id();

my $which = $field->get_widget_type;  # text, radio, etc..

# Get the element type object to which the field belongs.
my $elem = Bric::Biz::ElementType->lookup({ id => $field->get_element_type_id });

# Check authorization. We check the element, rather than the field, since
# field permissions are not (currently) supported.
#chk_authz($field, $id ? READ : CREATE);
#my $no_edit = !chk_authz($field, ($id ? EDIT : CREATE), 1);
chk_authz($elem, READ);
my $no_edit = !chk_authz($elem, EDIT, 1);
my $no_del = !$id || $no_edit;

my $exclude = { map { $_ => 1 } qw(
    key_name
    name
    max_length
    active
    wiget_type
    default_val
    length
    cols
    rows
    vals
    multiple
    precision
)};

# Get the name for the breadcrumb trail
my $crumb = $field->get_key_name();
$crumb = $crumb ? "&quot;$crumb&quot;" : 'New';
</%init>

<%doc>
###############################################################################

=head1 NAME

/admin/profile/field_type/dhandler - Interface for managing field types.

=head1 VERSION

$LastChangedRevision$

=head1 DATE

$LastChangedDate$

=head1 DESCRIPTION

This element handles the display for editing fields.

</%doc>
