<%#-- copyright OpenProject is a project management system. Copyright (C) 2012-2013 the OpenProject Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3. See doc/COPYRIGHT.rdoc for more details. ++#%> <%= error_messages_for 'custom_field' %>

<%= f.text_field :name, :required => true, :multi_locale => true %>

<%= f.select :field_format, custom_field_formats_for_select(@custom_field), {}, :onchange => "toggle_custom_field_format();", :disabled => !@custom_field.new_record? %>

<%= f.text_field :min_length, :size => 5, :no_label => true %> - <%= f.text_field :max_length, :size => 5, :no_label => true %>
(<%=l(:text_min_max_length_info)%>)

<%= f.text_field :regexp, :size => 50 %>
(<%=l(:text_regexp_info)%>)

<% if @custom_field.new_record? || @custom_field.field_format == 'list' %> <% possible_values = @custom_field.translations.inject({}) do |h, t| h[t.locale] = t.possible_values.to_a.join("\n") h end %> <%= f.text_area :possible_values, :value => possible_values, :rows => 15, :multi_locale => true %>
<% end %> <%= l(:text_custom_field_possible_values_info) %>

<% unless @custom_field.field_format == 'bool' %> <%= f.text_field(:default_value, :multi_locale => true) %> <% end %> <% if @custom_field.new_record? || ['date', 'float', 'int'].include?(@custom_field.field_format) %> <%= f.text_field(:default_value, :single_locale => true) %> <% end %>

<%= call_hook(:view_custom_fields_form_upper_box, :custom_field => @custom_field, :form => f) %>
<% case @custom_field.class.name when "WorkPackageCustomField" %>
<%=l(:label_type_plural)%> <% for type in @types %> <%= check_box_tag "custom_field[type_ids][]", type.id, (@custom_field.types.include? type), :id => "custom_field_type_ids_#{type.id}" %> <%= content_tag :label, (type.is_standard) ? l(:label_custom_field_default_type) : h(type), :class => "no-css", :for => "custom_field_type_ids_#{type.id}" %> <% end %> <%= hidden_field_tag "custom_field[type_ids][]", '' %>
 

<%= f.check_box :is_required %>

<%= f.check_box :is_for_all %>

<%= f.check_box :is_filter %>

<%= f.check_box :searchable %>

<% when "UserCustomField" %>

<%= f.check_box :is_required %>

<%= f.check_box :visible %>

<%= f.check_box :editable %>

<% when "ProjectCustomField" %>

<%= f.check_box :is_required %>

<%= f.check_box :visible %>

<%= f.check_box :searchable %>

<% when "TimeEntryCustomField" %>

<%= f.check_box :is_required %>

<% else %>

<%= f.check_box :is_required %>

<% end %> <%= call_hook(:"view_custom_fields_form_#{@custom_field.type.to_s.underscore}", :custom_field => @custom_field, :form => f) %>
<%= javascript_tag "toggle_custom_field_format();" %>