您现在的位置: 365建站网 > 365文章 > GAL中插件学习一(cssformbuilder)

GAL中插件学习一(cssformbuilder)

文章来源:365jz.com 点击数:201 更新时间:2009-09-24 22:32

A little plugin containing a form builder that uses css to produce tableless, lined-up forms.
一个包含用CSS来产生无表格、直排表单的表单生成器的小插件

功能
-   每个field label自动加到该input control的上方
-   每个input control 出现在最近control的右方(除非没有空间)
-   要强制把control放在新行,用
-   用{:class=>'half-size' } or {:class=>'double-size' }等这些html选项来改变control大小
-   用 class 'half-size', 'normal-size' or 'double-size' 勒令 select tags大小
-   用<% fieldset tag 'legend' %> [block] <% end %>来生成fieldset tags
-   作为默认,一个fieldset 扩充到右对齐;用html option{:class=>’continue’}来压缩fieldset,下一个fieldset将加在右边
-   支持用_()来对lables 和legens进行翻译(是通过首先calling CssBuilder.translate_as_gettext)(其实是在custom_envoirnment.rb中就call了); 或用String.t(by first calling CssBuilder.translate_as_globalize)
-   支持标准html form(css_form_for)和远程form(remote_css_form_for)
-    也包含一个show_builer(css_show_for),能用和同样的template file(如_form.rhtml)视它看起来和new/edit 的form一样,其中的field values 已经用html text 显示,而不用form和input control


example:
File app/views/customers/edit.rhtml: 
   <% css_form_for :customer, @customer, :url => { :action => 'update', :id => @customer } do |@f| %>
     <%= render :partial=> 'form' %>
     <%= submit_tag 'Edit' %>
   <% end %>
File app/views/customers/show.rhtml:
   <% css_show_for :customer, @customer,  do |@f| %>
     <%= render :partial=> 'form' %>
   <% end %>
另外还增加了

module ActionView::Helpers :: FormOptionsHelper #select_with_choises(object, method, choices, options = {}, html_options = {}) 这个select 支持choice
实际上是自制表单构建器:
      CssShowBuilder : css_show_builder.rb   这个挺有意思的
      CssFormBuilder: css_form_builder.rb
加上一些helper
     css_form_support.rb

生产内容,同时打通搜索引擎(SEO)与AI搜索引擎(GEO)流量入口的软件! 点击进入365建站器 »

您可能感兴趣的文章