Class: NitroRails::NitroFormHelper::NitroFormBuilder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- NitroRails::NitroFormHelper::NitroFormBuilder
- Includes:
- NitroRails::NitroOptionsHelper
- Defined in:
- app/helpers/nitro_rails/nitro_form_helper.rb
Instance Method Summary collapse
-
#generate_hidden_attribute_fields ⇒ Object
HIDDEN FIELDS ##.
- #hidden_affiliation_field(affiliation, **options) ⇒ Object
- #hidden_attribute_field(attribute, value, **options) ⇒ Object
-
#submit(text = nil, **options, &block) ⇒ Object
Don’t know if this works.
-
#submit_div(**options, &block) ⇒ Object
SUBMIT ##.
Methods included from NitroRails::NitroOptionsHelper
#nitro_defaults, #nitro_options
Instance Method Details
#generate_hidden_attribute_fields ⇒ Object
HIDDEN FIELDS ##
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/helpers/nitro_rails/nitro_form_helper.rb', line 59 def generate_hidden_attribute_fields() object_key = @object.class.name.underscore.to_sym attributes = {} if @object @object.changes.each do |attribute, (old_value, new_value)| attributes[attribute] = new_value end end if [:params] && [:params][object_key] attributes.merge!([:params][object_key]) end attributes.map do |attribute, value| hidden_attribute_field(attribute, value) end.join.html_safe + if [:belongs_to] hidden_affiliation_field([:belongs_to]) end end |
#hidden_affiliation_field(affiliation, **options) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/nitro_rails/nitro_form_helper.rb', line 81 def hidden_affiliation_field(affiliation, **) () do || .override(:value, affiliation.id) .default(:data, :nitro_form_target, "field") .concat(:data, :nitro_effects, "addToAffiliatedLists") .override(:data, :nitro_attribute, affiliation.nitro_id(@object.type.pluralize)) end hidden_field("#{affiliation.class.name.underscore}_id", **) end |
#hidden_attribute_field(attribute, value, **options) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'app/helpers/nitro_rails/nitro_form_helper.rb', line 92 def hidden_attribute_field(attribute, value, **) () do || .override(:value, value) .default(:data, :nitro_form_target, "field") .concat(:data, :nitro_effects, @object.attribute_effects(attribute).join(" ").camelize(:lower)) .override(:data, :nitro_attribute, attribute.to_s) end hidden_field(attribute, **) end |
#submit(text = nil, **options, &block) ⇒ Object
Don’t know if this works.
46 47 48 49 50 51 52 53 |
# File 'app/helpers/nitro_rails/nitro_form_helper.rb', line 46 def submit(text = nil, **, &block) () do || .default(:class, "btn button_to") .concat(:data, :action, "click->nitro-form#submit") end super(text, **, &block) end |
#submit_div(**options, &block) ⇒ Object
SUBMIT ##
36 37 38 39 40 41 42 43 |
# File 'app/helpers/nitro_rails/nitro_form_helper.rb', line 36 def submit_div(**, &block) () do || .default(:class, "nitro-form-submit") .concat(:data, :action, "click->nitro-form#submit") end @template.content_tag(:div, **, &block) end |