Class: ActionView::Helpers::FormBuilder
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder
- Defined in:
- lib/action_view/helpers/form_builder.rb
Instance Method Summary collapse
-
#full_errors(attribute, options = {}) ⇒ Object
———————-.
-
#has_many_fields(association) ⇒ Object
———————-.
-
#link_to_add_fields(association, options = {}) ⇒ Object
———————-.
-
#render_fields(partial, options = {}) ⇒ Object
———————-.
- #section(partial, options = {}, &block) ⇒ Object
Instance Method Details
#full_errors(attribute, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/action_view/helpers/form_builder.rb', line 39 def full_errors(attribute, ={}) @template.render( :partial => "/outpost/shared/full_errors", :locals => { :f => self, :attribute => attribute, :options => }) end |
#has_many_fields(association) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/action_view/helpers/form_builder.rb', line 69 def has_many_fields(association) partial = association.to_s.singularize fields = String.new self.object.send(association).each do |obj| fields << self.simple_fields_for(association, obj) do |nf| nf.render_fields(partial) end end fields.html_safe end |
#link_to_add_fields(association, options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/action_view/helpers/form_builder.rb', line 51 def link_to_add_fields(association, ={}) association = association.to_s partial = [:partial] || association.singularize title = [:title] || "Add Another #{association.singularize.titleize}" new_object = self.object.send(association).klass.new id = new_object.object_id fields = self.simple_fields_for(association, new_object, child_index: id) do |nf| nf.render_fields(partial) end @template.link_to(title, "#", class: "js-add-fields has-many-add-link", data: { id: id, build_target: [:build_target], fields: fields.gsub("\n", "") }) end |
#render_fields(partial, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/action_view/helpers/form_builder.rb', line 27 def render_fields(partial, ={}) @template.render( :partial => "/outpost/shared/fields/#{partial}_fields", :locals => { :f => self, :index => self.object.object_id, :options => }) end |
#section(partial, options = {}, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/action_view/helpers/form_builder.rb', line 14 def section(partial, ={}, &block) @template.render( :partial => "/outpost/shared/sections/#{partial}", :locals => { :f => self, :record => self.object, :options => , :extra => block_given? ? @template.capture(&block) : "" }) end |