diff options
author | José Valim <jose.valim@gmail.com> | 2009-08-30 16:53:23 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-08-30 16:53:23 +0200 |
commit | 5d645c271b350c2a3ed7fd835e539322cda61d8c (patch) | |
tree | b65504c9483bbfa9123fa7b6aefa5b80a2e3421d /railties/lib | |
parent | 0fc5c59b37b4e2a809213c63bc9018bee7dc4aaf (diff) | |
download | rails-5d645c271b350c2a3ed7fd835e539322cda61d8c.tar.gz rails-5d645c271b350c2a3ed7fd835e539322cda61d8c.tar.bz2 rails-5d645c271b350c2a3ed7fd835e539322cda61d8c.zip |
Change scaffold to use _form as partial and div's instead of paragraphs. [#1760 status:resolved]
Diffstat (limited to 'railties/lib')
6 files changed, 25 insertions, 31 deletions
diff --git a/railties/lib/generators.rb b/railties/lib/generators.rb index 5c03787aee..879abb1c41 100644 --- a/railties/lib/generators.rb +++ b/railties/lib/generators.rb @@ -45,7 +45,6 @@ module Rails }, :erb => { - :form => false, :layout => true }, diff --git a/railties/lib/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/generators/erb/scaffold/scaffold_generator.rb index 955f22192a..f146a1b1da 100644 --- a/railties/lib/generators/erb/scaffold/scaffold_generator.rb +++ b/railties/lib/generators/erb/scaffold/scaffold_generator.rb @@ -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 diff --git a/railties/lib/generators/erb/scaffold/templates/_form.html.erb b/railties/lib/generators/erb/scaffold/templates/_form.html.erb new file mode 100644 index 0000000000..473ebe14fb --- /dev/null +++ b/railties/lib/generators/erb/scaffold/templates/_form.html.erb @@ -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 %> diff --git a/railties/lib/generators/erb/scaffold/templates/edit.html.erb b/railties/lib/generators/erb/scaffold/templates/edit.html.erb index cca1d61c68..5bc507ffc8 100644 --- a/railties/lib/generators/erb/scaffold/templates/edit.html.erb +++ b/railties/lib/generators/erb/scaffold/templates/edit.html.erb @@ -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 %>
\ No newline at end of file +<%%= link_to 'Back', <%= plural_name %>_path %> diff --git a/railties/lib/generators/erb/scaffold/templates/new.html.erb b/railties/lib/generators/erb/scaffold/templates/new.html.erb index 96c89fc50e..9a1c489331 100644 --- a/railties/lib/generators/erb/scaffold/templates/new.html.erb +++ b/railties/lib/generators/erb/scaffold/templates/new.html.erb @@ -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 %>
\ No newline at end of file +<%%= link_to 'Back', <%= plural_name %>_path %> diff --git a/railties/lib/generators/rails/stylesheets/templates/scaffold.css b/railties/lib/generators/rails/stylesheets/templates/scaffold.css index 093c20994d..163f11441c 100644 --- a/railties/lib/generators/rails/stylesheets/templates/scaffold.css +++ b/railties/lib/generators/rails/stylesheets/templates/scaffold.css @@ -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; |