1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Change scaffold to use _form as partial and div's instead of paragraphs. [#1760 status:resolved]

This commit is contained in:
José Valim 2009-08-30 16:53:23 +02:00
parent 0fc5c59b37
commit 5d645c271b
6 changed files with 25 additions and 31 deletions

View file

@ -45,7 +45,6 @@ module Rails
},
:erb => {
:form => false,
:layout => true
},

View file

@ -7,7 +7,6 @@ module Erb
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
class_option :form, :type => :boolean
class_option :layout, :type => :boolean
class_option :singleton, :type => :boolean, :desc => "Supply to skip index view"
@ -33,7 +32,6 @@ module Erb
end
def copy_form_file
return unless options[:form]
copy_view :_form
end

View file

@ -0,0 +1,17 @@
<%% form_for(@<%= singular_name %>) do |f| %>
<%%= f.error_messages %>
<% for attribute in attributes -%>
<div class="attribute">
<%%= f.label :<%= attribute.name %> %><br />
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
</div>
<% end -%>
<div class="action">
<%% if @<%= singular_name %>.new_record? %>
<%%= f.submit 'Create' %>
<%% else %>
<%%= f.submit 'Update' %>
<%% end %>
</div>
<%% end %>

View file

@ -1,18 +1,6 @@
<h1>Editing <%= singular_name %></h1>
<%% form_for(@<%= singular_name %>) do |f| %>
<%%= f.error_messages %>
<% for attribute in attributes -%>
<p>
<%%= f.label :<%= attribute.name %> %><br />
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
</p>
<% end -%>
<p>
<%%= f.submit 'Update' %>
</p>
<%% end %>
<%%= render 'form' %>
<%%= link_to 'Show', @<%= singular_name %> %> |
<%%= link_to 'Back', <%= plural_name %>_path %>
<%%= link_to 'Back', <%= plural_name %>_path %>

View file

@ -1,17 +1,5 @@
<h1>New <%= singular_name %></h1>
<%% form_for(@<%= singular_name %>) do |f| %>
<%%= f.error_messages %>
<%%= render 'form' %>
<% for attribute in attributes -%>
<p>
<%%= f.label :<%= attribute.name %> %><br />
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
</p>
<% end -%>
<p>
<%%= f.submit 'Create' %>
</p>
<%% end %>
<%%= link_to 'Back', <%= plural_name %>_path %>
<%%= link_to 'Back', <%= plural_name %>_path %>

View file

@ -16,6 +16,10 @@ a { color: #000; }
a:visited { color: #666; }
a:hover { color: #fff; background-color:#000; }
div.attribute, div.action {
margin-bottom: 10px;
}
.fieldWithErrors {
padding: 2px;
background-color: red;