Permalink
Browse files

added form partial

  • Loading branch information...
1 parent f12bfae commit 8f9ae16bdcc99f06897dc21d33e0362aa2a7bedc @pilu pilu committed Jul 28, 2009
View
11 rails_generators/themed/templates/view_edit.html.erb
@@ -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>
View
10 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>
View
11 rails_generators/themed/templates/view_new.html.erb
@@ -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>
View
68 rails_generators/themed/templates/view_tables.html.erb
@@ -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>
View
1 rails_generators/themed/themed_generator.rb
@@ -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"))

0 comments on commit 8f9ae16

Please sign in to comment.