标签:inline htm ide com 技术 checkbox ble sub ati
通过新建lib/templates/erb/scaffold/_form.html.erb,来重写scaffold生成view下_form.html.erb的默认模板
Bootstrap: Basic Form:
<%%= simple_form_for(@<%= singular_table_name %>) do |f|%> <%%= f.error_notification%> <div class="col-md-6"> <div class="form-inputs"> <%- attributes.each do |attribute| -%> <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>%> <%- end -%> </div> </div> <div class="form-actions"> <%%= f.button :submit %> </div> <%% end %>
Simple Form: Inline Form
<%%= simple_form_for @aab, wrapper: :inline_form, html: { class: ‘form-inline‘ } do |f| %> <%%= f.error_notification %> <%- attributes.each do |attribute| -%> <%%= f.<%= attribute.reference? ? :association : :input%>:<%= attribute.name%>, placeholder: ‘Enter <%= attribute.name%>‘%> <%- end -%> <%%=f.button :submit %> <%% end%>
Simple Form: Horizontal Form
<%%= simple_form_for @<%= singular_table_name%>, as: ‘user_horizontal‘, html: { class: ‘form-horizontal‘ }, wrapper: :horizontal_form, wrapper_mappings: { check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input, boolean: :horizontal_boolean } do |f| %> <%%= f.error_notification %> <div class="col-md-6"> <div class="form-inputs"> <%- attributes.each do |attribute| -%> <%%= f.<%= attribute.reference? ? :association : :input%>:<%= attribute.name%>, placeholder: ‘<%= attribute.name%>‘%> <%- end -%> <%%= f.input :file, as: :file %> <%%= f.input :sex, as: :radio_buttons, collection: ["Male", "Female"] %> </div> </div> <%%= f.button :submit %> <%% end %>
简略版本
<%%= simple_form_for @<%= singular_table_name%>, as: ‘user_horizontal‘, html: { class: ‘form-horizontal‘ }, wrapper: :horizontal_form do |f| %> <%%= f.error_notification %> <div class="col-md-6"> <div class="form-inputs"> <%- attributes.each do |attribute| -%> <%%= f.<%= attribute.reference? ? :association : :input%>:<%= attribute.name%>, placeholder: ‘<%= attribute.name%>‘%> <%- end -%> </div> </div> <%%= f.button :submit %> <%% end %>
标签:inline htm ide com 技术 checkbox ble sub ati
原文地址:http://www.cnblogs.com/tabCtrlShift/p/6102047.html