<% # CODE NOTES: # This is meant to be used as a nested form inside other forms, so that multiple prompts can be submitted within a single form. # It is also meant to be used with javascript-based live adding (that is, not with ajax) which means locals will not be re-evaluated when it is added; # keep this in mind when using the add_section code! # It expects a form being passed in as "form" # If the local variable "index" is passed in, that will represent which prompt this is, if there are multiple prompts being submitted # If the local variable "required" is passed in, this prompt is required # See the challenge_signup form for an example of how this is used. %> <% index ||= 0 %> <% required ||= false %> <% prompt_label = form.object.class.name %> <% prompt_type = prompt_label.downcase %> <% prompt_types = prompt_type.pluralize %> <% restriction = @challenge.send("#{prompt_type}_restriction") %>
<% if index.is_a? String %> <% prompt_label += " #{index}" %> <% else %> <% prompt_label += " #{(index + 1)}" %> <% end %> <%= prompt_label %>

<%= form.object.new_record? ? prompt_label : link_to(prompt_label, collection_prompt_path(@collection, form.object)) %>

<% if restriction.title_allowed %> > <% if restriction.title_required %> <%= form.label :title, (ts("Title:") + " *") %> <% else %> <%= form.label :title, ts("Title:") %> <% end %>
<%= form.text_field :title %>
<% end %> <%= render "prompts/prompt_form_tag_options", :form => form, :restriction => restriction %> <% if restriction.url_allowed %> > <% url_label = @challenge.send("#{prompt_type}_url_label") %> <% if restriction.url_required %> <%= form.label :url , (url_label.blank? ? (ts("Prompt URL:") + " *") : url_label + " *") %> <% else %> <%= form.label :url , (url_label.blank? ? ts("Prompt URL:") : url_label) %> <% end %>
<%= form.text_field :url %>
<% end %> <% if restriction.description_allowed %> > <% desc_label = @challenge.send("#{prompt_type}_description_label") %> <% if restriction.description_required %> <%= form.label :description, (desc_label.blank? ? (ts("Description:") + " *") : desc_label + " *") %> <% else %> <%= form.label :description, (desc_label.blank? ? ts("Description:") : desc_label) %> <% end %>
<%= form.text_area :description, :rows => 6, :cols => 50, :class => "observe_textlength" %> <%= live_validation_for_field(field_id(form, "description").to_sym, :presence => false, :maximum_length => ArchiveConfig.NOTES_MAX) -%> <%= generate_countdown_html(field_id(form, "description").to_sym, ArchiveConfig.NOTES_MAX) %>
<% end %> <% if restriction.optional_tags_allowed %> <% form.object.build_optional_tag_set unless form.object.optional_tag_set %> <%= form.fields_for :optional_tag_set_attributes do |optional_tag_set_form| %>
<%= optional_tag_set_form.label :tagnames, ts("Optional Tags:") %> <%= link_to_help("challenge-optional-tags-user")%>
<%= optional_tag_set_form.text_field :tagnames, autocomplete_options("tag?type=all", :value => form.object.optional_tag_set.tagnames) %>
<% end %> <% end %> <% if @collection.challenge.respond_to?(:anonymous) %> <% # TODO ANONYMITY REFACTOR: Anonymity should not be based on a type of challenge but on whether the specific challenge ALLOWS anonymity or not, # (currently the prompt memes don't allow a mod to specify no anonymity allowed) # and should probably be done via an Anonymous user like the Orphan user. %>
<%= form.label :anonymous, ts("Semi-anonymous Prompt?") %>
<%= form.check_box :anonymous, :checked => @collection.challenge.anonymous? ? true : form.object.anonymous %>

<%= ts("(Note: This is not totally secure, and is still guessable in some places.)") %>

<% end %>
<% unless required %>

<%= link_to_remove_section(ts("Remove?"), form) %>

<% end %>