资源说明:Helper methods to ease form creation
= ExtendedFormHelper Helper methods to ease form creation Note that all e_xxx are just wrapers, so all non mentioned options are send directly to underlying method All methods work as expected in form_for: <% form_for(:page) do |f| %> <%= f.e_text_field(:title, :label => true) %> <%= f.e_text_area(:text, :label => true, :before => 'description') %> <%- f.e_check_box(:agree, :label => true) do |c| -%> <%= c %> <%= render 'agreement' %> <%- end -%> <%= f.e_submit %> <% end %> == Examples === e_text_field <%= f.e_text_field(:title) %>with hint: <%= f.e_text_field(:title, :hint => 'input some text') %>with error: <%= f.e_text_field(:title) %>with errors: <%= f.e_text_field(:title) %>not goodwith label: <%= f.e_text_field(:title, :label => 'Input text') %>
- not good
- not bad
with label from I18n (define translation for 'page.title'): <%= f.e_text_field(:title, :label => true) %>with class: <%= f.e_text_field(:title, :class => 'superField') %>with content before and after: <%= f.e_text_field(:title, :before => 'before', :after => 'after') %>before afterin block form: <%- f.e_text_field(:title) do |c| -%> before <%= c %> after <%- end -%>before afterbesides to_str method (called implicitly - concats label, control and errors), there are methods label, control and errors === e_text_area, e_file_field, e_check_box same as e_text_field: <%= f.e_text_area(:title, :label => 'Input text') %> <%= f.e_file_field(:title, :label => 'Input text') %> <%= f.e_check_box(:title, :label => 'Input text') %>=== e_password_field same as e_text_field, but value is not automatically inserted: <%= f.e_password_field(:title, :label => 'Input text') %>pass :value => true to insert: <%= f.e_password_field(:title, :value => true) %>=== e_submit <%= f.e_submit('save') %>getting values from I18n (define translation for 'page.create' and 'page.save'): <%= f.e_submit %>=== custom control def trigger(object_name, method, options) 'i am trigger' end <%= f.e_control(:trigger, :switch_column) %>as block: def super_trigger(object_name, method, options) 'i am triggeri am super trigger' end <%- e_control(:super_trigger, :switch_column) do |c| -%> before <%= c %> after <%- end -%>beforei am super triggerafter
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。