summaryrefslogtreecommitdiff
path: root/app/views/tournaments/_selected.html.erb
blob: eec8b5efcae38f6b20486c3c0db0ecfe24b2e553 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<%= form_for(@tournament) do |f| %>
  <%= render "common/error_messages", :target => @tournament %>
  <%= f.hidden_field(:game_id) %>

  <% @game = Game.find(params[:game]) %>
  <% @tournament.attributes.each do |name, value| %>
    <% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") or (name == "set_rounds") %>
      <% next %>
    <% end %>
    <p>
      <%= f.label name %><br>
      <% if !@game.attributes[name].nil? %>
        <%= f.text_field(name, :value => @game.attributes[name] ) %>
      <% else %>
        <%= f.text_field name %>
      <% end  %>
    </p>
  <% end %>

  <%= fields_for "tournament[settings]", @tournament.settings do |setting_fields|  %>
    <% @tournament.settings.each do |setting| %>
      <p>
      <%= setting_fields.label setting.name %>
      <br>
      <% case setting.stype %>
        <% when 0 %>
           <%= setting_fields.text_field( setting.name ) %>
        <% when 1 %>
           <%= setting_fields.text_area( setting.name ) %>
        <% when 2 %>
           <%= setting_fields.collection_radio_buttons( setting.name, setting.type_opt.split(','), :first, :last, { item_wrapper_tag: false } ) %>
        <% when 3 %>
           <%= setting_fields.collection_check_boxes( setting.name, setting.type_opt.split(','), :first, :last, { item_wrapper_tag: false } ) %>
        <% when 4 %>
           <%= setting_fields.radio_button( setting.name, "true" ) %>
           <%= setting_fields.radio_button( setting.name, "false" ) %>
        <% when 5 %>
           <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %>
        <% end %>
      <% end %>
      </p>
    <% end %>
  <%= f.submit %>
<% end %>