+ if($input == 'hidden') {
+ $hidden_fields[] = array('name' => $name);
+ } else {
+ $visible_fields[] = array($input => array(
+ 'name' => $name,
+ 'caption' => format_caption($name)));
+ }
+
+ if($input == 'image' || $input == 'file') {
+ $tem->set('uploads');
+ $tem->set('enctype_attr', '" enctype="multipart/form-data');
+ } elseif($input == 'html') {
+ $has_html_editors = true;
+ $tem->set('html_field_name', $name);
+ $tem->set('replace_textarea');
+ }
+
+ switch($input) {
+ case 'image':
+ case 'checkbox':
+ case 'date':
+ case 'textarea':
+ case 'html':
+ $display_type = $input;
+ break;
+ default:
+ $display_type = 'short';
+ }
+ if($format != 'n/a') {
+ $display_fields[] = array($display_type => array(
+ 'name' => $name, 'caption' => format_caption($name)));
+ }
+
+ if(show_in_listing($type, $input, $format, $sql)) {
+ $listing_headers[] = array('caption' => format_caption($name));
+ $listing_field = array('name' => $name);
+ if($format == 'bool' || $format == 'yesno') {
+ $listing_field['enc'] = 'yesno';
+ } elseif($input == 'date') {
+ $listing_field['enc'] = 'mmddyyyy';
+ } elseif($type == 'thumb') {
+ $listing_field['thumb'] = true;
+ } else {
+ $listing_field['enc'] = 'html';
+ }
+ $listing_fields[] = $listing_field;
+ }
+ }
+
+ # Submit/Send button
+ if($GLOBALS['opt_email'] == 'Yes' && $GLOBALS['opt_db'] != 'Yes') {
+ $visible_fields[] = array('submit' => array(
+ 'name' => 'send',
+ 'caption' => 'Send'));
+ } else {
+ $visible_fields[] = array('submit' => array(
+ 'name' => 'save',
+ 'caption' => 'Save'));
+ }
+
+ $tem->set('form', array(
+ 'visible_fields' => $visible_fields,
+ 'hidden_fields' => $hidden_fields));
+
+ # opt_display and opt_listing control whether these are actually displayed
+ $tem->set('display_fields', $display_fields);
+ $tem->set('listing_headers', $listing_headers);
+ $tem->set('listing_fields', $listing_fields);
+
+
+ if($has_html_editors) {
+ $tem->set('html_editor_headers');