Skip to content

Instantly share code, notes, and snippets.

@cooljl31
Created January 25, 2023 10:49
Show Gist options
  • Select an option

  • Save cooljl31/486923dd4d9f3fe66c1d718605fb0538 to your computer and use it in GitHub Desktop.

Select an option

Save cooljl31/486923dd4d9f3fe66c1d718605fb0538 to your computer and use it in GitHub Desktop.

Revisions

  1. cooljl31 created this gist Jan 25, 2023.
    8 changes: 8 additions & 0 deletions SimpleForm custom ArrayInput
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #Simple form Input class for arrays
    class ArrayInput < SimpleForm::Inputs::Base
    def input(_wrapper_options)
    #override the attribute name for arrays to allow rails to handle array forms
    input_html_options.merge!({:name => "#{self.object_name}[#{attribute_name}][]"})
    @builder.text_field(attribute_name, input_html_options)
    end
    end