Skip to content

Commit

Permalink
added form partial
Browse files Browse the repository at this point in the history
  • Loading branch information
gravityblast committed Jul 28, 2009
1 parent f12bfae commit 8f9ae16
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 55 deletions.
11 changes: 1 addition & 10 deletions rails_generators/themed/templates/view_edit.html.erb
Expand Up @@ -11,16 +11,7 @@
<h2 class="title">Edit <%= model_name %></h2>
<div class="inner">
<%% form_for @<%= model_name.downcase %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => :form } do |f| -%>
<% columns.each do |column| %>
<div class="group">
<%%= f.label :<%= column.name %>, "<%= column.name.capitalize %>", :class => :label %>
<%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
<span class="description">Ex: a simple text</span>
</div>
<%- end -%>
<div class="group navform">
<input type="submit" class="button" value="Save &rarr;" /> or <%%= link_to 'Cancel', <%= controller_routing_path %>_path %>
</div>
<%%= render :partial => "form", :locals => {:f => f} %>
<%% end -%>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions rails_generators/themed/templates/view_form.html.erb
@@ -0,0 +1,10 @@
<% columns.each do |column| %>
<div class="group">
<%%= f.label :<%= column.name %>, "<%= column.name.capitalize %>", :class => :label %>
<%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
<span class="description">Ex: a simple text</span>
</div>
<%- end -%>
<div class="group navform">
<input type="submit" class="button" value="Save &rarr;" /> or <%%= link_to 'Cancel', <%= controller_routing_path %>_path %>
</div>
11 changes: 1 addition & 10 deletions rails_generators/themed/templates/view_new.html.erb
Expand Up @@ -10,16 +10,7 @@
<h2 class="title">New <%= model_name %></h2>
<div class="inner">
<%% form_for :<%= model_name.downcase %>, :url => <%= controller_routing_path %>_path, :html => { :class => :form } do |f| -%>
<% columns.each do |column| %>
<div class="group">
<%%= f.label :<%= column.name %>, "<%= column.name.capitalize %>", :class => :label %>
<%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
<span class="description">Ex: a simple text</span>
</div>
<%- end -%>
<div class="group navform">
<input type="submit" class="button" value="Save &rarr;" /> or <%%= link_to 'Cancel', <%= controller_routing_path %>_path %>
</div>
<%%= render :partial => "form", :locals => {:f => f} %>
<%% end -%>
</div>
</div>
Expand Down
68 changes: 33 additions & 35 deletions rails_generators/themed/templates/view_tables.html.erb
Expand Up @@ -9,42 +9,40 @@
<div class="content">
<h2 class="title">All <%= plural_model_name %></h2>
<div class="inner">
<%% form_tag "", :class => :form do -%>
<table class="table">
<tr>
<th class="first">ID</th>
<th><%= columns.first.name.capitalize %></th>
<th>Created at</th>
<th class="last">&nbsp;</th>
</tr>
<%% @<%= plural_resource_name %>.each do |<%= resource_name %>| -%>
<tr>
<td>
<%%= <%= resource_name %>.id %>
</td>
<td>
<%%= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %>
</td>
<td>
<%%= <%= resource_name %>.created_at %>
</td>
<td class="last">
<%%= link_to 'show', <%= singular_controller_routing_path %>_path(<%= resource_name %>) %> |
<%%= link_to 'edit', edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>) %> |
<%%= link_to 'destroy', <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => 'Are you sure?' %>
</td>
</tr>
<%% end -%>
</table>
<div class="actions-bar">
<div class="actions">
</div>
<% if options[:will_paginate] %>
<%%= will_paginate @<%= resource_name %> %>
<% end %>
<div class="clear"></div>
<table class="table">
<tr>
<th class="first">ID</th>
<th><%= columns.first.name.capitalize %></th>
<th>Created at</th>
<th class="last">&nbsp;</th>
</tr>
<%% @<%= plural_resource_name %>.each do |<%= resource_name %>| -%>
<tr>
<td>
<%%= <%= resource_name %>.id %>
</td>
<td>
<%%= link_to <%= resource_name %>.<%= columns.first.name %>, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %>
</td>
<td>
<%%= <%= resource_name %>.created_at %>
</td>
<td class="last">
<%%= link_to 'show', <%= singular_controller_routing_path %>_path(<%= resource_name %>) %> |
<%%= link_to 'edit', edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>) %> |
<%%= link_to 'destroy', <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :confirm => 'Are you sure?' %>
</td>
</tr>
<%% end -%>
</table>
<div class="actions-bar">
<div class="actions">
</div>
<%% end -%>
<% if options[:will_paginate] %>
<%%= will_paginate @<%= resource_name %> %>
<% end %>
<div class="clear"></div>
</div>
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions rails_generators/themed/themed_generator.rb
Expand Up @@ -48,6 +48,7 @@ def manifest_for_crud(m)
m.template('view_tables.html.erb', File.join("app/views", @controller_file_path, "index.html.erb"))
m.template('view_new.html.erb', File.join("app/views", @controller_file_path, "new.html.erb"))
m.template('view_edit.html.erb', File.join("app/views", @controller_file_path, "edit.html.erb"))
m.template('view_form.html.erb', File.join("app/views", @controller_file_path, "_form.html.erb"))
m.template('view_show.html.erb', File.join("app/views", @controller_file_path, "show.html.erb"))
m.template('view_sidebar.html.erb', File.join("app/views", @controller_file_path, "_sidebar.html.erb"))

Expand Down

0 comments on commit 8f9ae16

Please sign in to comment.