{* Should be included and past the variables 'custom_fields' (an array of custom fields) and
'form_type' which should be either 'anonymous' or 'report' *}
<script>
{literal}
var custom_fields_info = new Array();
{/literal}
</script>
{section name="i" loop=$custom_fields}
{assign var='fld_id' value=$custom_fields[i].fld_id}
{assign var="custom_field_id" value=$custom_fields[i].fld_id}
{if $form_type == 'report'}
  {assign var="cf_required" value=$custom_fields[i].fld_report_form_required}
{elseif $form_type == 'anonymous'}
  {assign var="cf_required" value=$custom_fields[i].fld_anonymous_form_required}
{elseif $form_type == 'close'}
  {assign var="cf_required" value=$custom_fields[i].fld_close_form_required}
{/if}
<tr>
  <td width="150" bgcolor="{$cell_color}" class="default_white">
    <b>{$custom_fields[i].fld_title}:{if $cf_required} *{/if}</b>
    <script language="JavaScript">
    <!--
    fld_id = {$custom_fields[i].fld_id};
    {literal}
    custom_fields_info[custom_fields_info.length] = {
        id: fld_id,
        type: '{/literal}{$custom_fields[i].fld_type}{literal}',
        title: '{/literal}{$custom_fields[i].fld_title}{literal}',
        required: '{/literal}{$cf_required}{literal}',
        validation_js: {/literal}{$custom_fields[i].validation_js|default:"''"}{literal}
        }

    {/literal}
    //-->
    </script>
  </td>
  <td bgcolor="{$light_color}">
    {if $custom_fields[i].fld_type == 'text'}
    <input id="custom_field_{$custom_fields[i].fld_id}" class="default" type="text" name="custom_fields[{$custom_fields[i].fld_id}]" maxlength="255" size="50" tabindex="{$tabindex++}" value="{$smarty.request.custom_fields[$fld_id]|default:$custom_fields[i].value}">
    {elseif $custom_fields[i].fld_type == 'integer'}
    <input id="custom_field_{$custom_fields[i].fld_id}" class="default" type="text" name="custom_fields[{$custom_fields[i].fld_id}]" maxlength="255" size="10" tabindex="{$tabindex++}" value="{$smarty.request.custom_fields[$fld_id]|default:$custom_fields[i].value}">
    </script>
    {elseif $custom_fields[i].fld_type == 'textarea'}
    <textarea id="custom_field_{$custom_fields[i].fld_id}" name="custom_fields[{$custom_fields[i].fld_id}]" rows="10" cols="60" tabindex="{$tabindex++}">{$smarty.request.custom_fields[$fld_id]|default:$custom_fields[i].value}</textarea>
    {elseif $custom_fields[i].fld_type == 'date'}
    {html_select_date field_array="custom_fields[`$custom_fields[i].fld_id`]" prefix='' all_extra="class=\"default\"" month_empty='' time=$custom_fields[i].value|default:"0000-00-00" display_years=false display_days=false month_extra="id=\"custom_field_`$custom_field_id`_month\" tabindex=\"`$tabindex++`\""}
    {include file="error_icon.tpl.html" field="custom_fields[$custom_field_id][Month]"}
    {html_select_date field_array="custom_fields[`$custom_fields[i].fld_id`]" prefix='' all_extra="class=\"default\"" day_empty='' time=$custom_fields[i].value|default:"0000-00-00" display_months=false display_years=false day_value_format=%02d day_extra="id=\"custom_field_`$custom_field_id`_day\" tabindex=\"`$tabindex++`\""}
    {include file="error_icon.tpl.html" field="custom_fields[$custom_field_id][Day]"}
    {html_select_date field_array="custom_fields[`$custom_fields[i].fld_id`]" prefix='' all_extra="class=\"default\"" year_empty='' time=$custom_fields[i].value|default:"0000-00-00" display_months=false display_days=false start_year=-1 end_year=+2 year_extra="id=\"custom_field_`$custom_field_id`_year\" tabindex=\"`$tabindex++`\""}
    {include file="error_icon.tpl.html" field="custom_fields[$custom_field_id][Year]"}
    {else}
    <select id="custom_field_{$custom_fields[i].fld_id}" {if $custom_fields[i].fld_type == 'multiple'}multiple size="3"{/if} class="default" name="custom_fields[{$custom_fields[i].fld_id}]{if $custom_fields[i].fld_type == 'multiple'}[]{/if}" tabindex="{$tabindex++}">
      {if $custom_fields[i].fld_type != 'multiple'}<option value="-1">{t}Please choose an option{/t}</option>{/if}
      {html_options options=$custom_fields[i].field_options selected=$smarty.request.custom_fields[$fld_id]|default:$custom_fields[i].selected_cfo_id}
    </select>
    {/if}
    {if $custom_fields[i].dynamic_options|@count > 0}
    <script>custom_field_init_dynamic_options({$custom_fields[i].fld_id});</script>
    {/if}
    {if $custom_fields[i].fld_type == 'multiple'}
      {assign var="custom_field_sufix" value="[]"}
    {else}
      {assign var="custom_field_sufix" value=""}
    {/if}
    {include file="error_icon.tpl.html" field="custom_fields[$custom_field_id]$custom_field_sufix"}
    {if $custom_fields[i].fld_description != ""}
    <span class="small_default">({$custom_fields[i].fld_description|escape:"html"})</span>
    {/if}
  </td>
</tr>
{/section}
