From 295d934e76a885cabb7e2cd19ada9aebb23487f1 Mon Sep 17 00:00:00 2001 From: Mike Mayo Date: Thu, 6 Oct 2011 23:54:25 -0500 Subject: [PATCH] formtastic support --- app/assets/stylesheets/web-app-theme/base.css | 3 ++- .../themed/templates/view_edit.html.erb | 2 +- .../themed/templates/view_form.html.erb | 13 ++++++++++++- .../themed/templates/view_new.html.erb | 2 +- .../web_app_theme/themed/themed_generator.rb | 1 + 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/web-app-theme/base.css b/app/assets/stylesheets/web-app-theme/base.css index 3edafef..fca3e11 100644 --- a/app/assets/stylesheets/web-app-theme/base.css +++ b/app/assets/stylesheets/web-app-theme/base.css @@ -22,7 +22,8 @@ h3 { font-size: 18px; margin: 10px 0; font-weight: normal;} h4 { font-size: 16px; margin: 10px 0; font-weight: normal;} hr {height: 1px; border: 0; } p { margin: 15px 0;} -a img { border: none; } +a img, fieldset { border: none; } +ol { list-style-type: none; } body { font-size: 12px; diff --git a/lib/generators/web_app_theme/themed/templates/view_edit.html.erb b/lib/generators/web_app_theme/themed/templates/view_edit.html.erb index 837d7b2..33541ca 100644 --- a/lib/generators/web_app_theme/themed/templates/view_edit.html.erb +++ b/lib/generators/web_app_theme/themed/templates/view_edit.html.erb @@ -9,7 +9,7 @@

<%%= t("web-app-theme.edit", :default => "Edit") %> <%= model_name %>

- <%%= form_for @<%= model_name.underscore %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => :form } do |f| -%> + <%%= <% if options.formtastic %>semantic_<% end %>form_for @<%= model_name.underscore %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => 'form' } do |f| -%> <%%= render :partial => "form", :locals => {:f => f} %> <%% end -%>
diff --git a/lib/generators/web_app_theme/themed/templates/view_form.html.erb b/lib/generators/web_app_theme/themed/templates/view_form.html.erb index bdf964e..a84c15d 100644 --- a/lib/generators/web_app_theme/themed/templates/view_form.html.erb +++ b/lib/generators/web_app_theme/themed/templates/view_form.html.erb @@ -1,10 +1,21 @@ +<% if options.formtastic %> +<% unless columns.blank? -%> + <%%= f.inputs do %> + <% columns.each do |column| %> + <%%= f.input :<%= column.name %>, :wrapper_html => { :class => 'group' }, :label_html => { :class => 'label' }, :input_html => { :class => '<%= column.field_type %>' } %> + <%- end -%> + + <%% end -%> +<%- end -%> +<%- else -%> <% columns.each do |column| %>
<%%= f.label :<%= column.name %>, t("activerecord.attributes.<%= model_name.underscore %>.<%= column.name %>", :default => "<%= column.name.humanize %>"), :class => :label %> <%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %> Ex: a simple text
-<%- end -%> +<%- end -%> +<%- end -%>