Skip to content

Allow to set wrapper mappings when SimpleForm.setup #1757

Open
@ghost

Description

Like #1632, I want to specify different wrapper mappings for each wrapper of form.
So, I would like to be able to specify the wrapper mappings for the wrapper of form when SimpleForm.setup.

# config/initializers/simple_form.rb
SimpleForm.setup do |config|
  # ...

  horizontal_forms_mapping = {
    boolean:       :horizontal_boolean,
    check_boxes:   :horizontal_collection,
    date:          :horizontal_multi_select,
    datetime:      :horizontal_multi_select,
    file:          :horizontal_file,
    radio_buttons: :horizontal_collection,
    range:         :horizontal_range,
    time:          :horizontal_multi_select
  }

  # horizontal form wrapper
  config.wrappers :horizontal_form, tag: 'div', class: 'mb-4', wrapper_mappings: horizontal_forms_mapping do |b|
    b.use :html5
    b.use :placeholder

    # ...

  end

  # ...
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions