summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-03-04 20:38:23 -0500
committerTomer Kimia <tkimia@purdue.edu>2014-03-04 20:38:23 -0500
commit17755b3c36b93410fcb10a5b9464d886da2d8099 (patch)
treedb59503556fbb123ddc4cdf1efbd52a8bdbd050c /app
parentdb025e713efc8bfeb43b3fc5d2c54b89e1fa1867 (diff)
dynamic formgit add app/views/tournaments/new.html.erb app/views/tournaments/_selected.html.erb
Diffstat (limited to 'app')
-rw-r--r--app/views/tournaments/_selected.html.erb30
-rw-r--r--app/views/tournaments/new.html.erb2
2 files changed, 29 insertions, 3 deletions
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
index 3b14404..4277d8e 100644
--- a/app/views/tournaments/_selected.html.erb
+++ b/app/views/tournaments/_selected.html.erb
@@ -1,5 +1,31 @@
+<%= form_for(@tournament) do |f| %>
+ <% if @tournament.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@tournament.errors.count, "error") %> prohibited this tournament from being saved:</h2>
- <%= content_tag(:p, "Hello World") %>
+ <ul>
+ <% @tournament.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+ <%# this is the dynamic script to output fields to the form %>
+ <% @chosen = Game.find(@game) %>
+ <% @chosen.attributes.each do |name, value| %>
+ <% if name == "id" %>
+ <% next %>
+ <% end %>
+ <% if name == "created_at" %>
+ <% break %>
+ <% end %>
+ <p>
+ <label for=<%= name %>><%= name.capitalize.gsub('_', ' ') %></label>
+ <br />
+ <input type="text" id=<%= name %> value=<%= value %>>
+ </p>
+ <% end %>
-<%= tag(:label, for: 'GameType') %> \ No newline at end of file
+ <%= f.submit %>
+<% end %>
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index a6dfa4d..428487a 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -1,6 +1,6 @@
<%= javascript_include_tag :defaults %>
-<h1>New tournament</h1>
+<h1>New Tournament</h1>
<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %> <%= link_to 'Select', 'new?game=1', :class => "btn btn-warning btn-lg" %>