{"record":{"id":"c35c3ae91636d904","repo":"heartcombo/simple_form","slug":"couldn-t-find-wrapper-with-name-name","errorCode":null,"errorMessage":"Couldn't find wrapper with name #{name}","messagePattern":"Couldn't find wrapper with name #(.+?)","errorType":"exception","errorClass":"WrapperNotFound","httpStatus":null,"severity":"error","filePath":"lib/simple_form.rb","lineNumber":222,"sourceCode":"\n  ## WRAPPER CONFIGURATION\n  # The default wrapper to be used by the FormBuilder.\n  mattr_accessor :default_wrapper\n  @@default_wrapper = :default\n  @@wrappers = {} #:nodoc:\n\n  mattr_accessor :i18n_scope\n  @@i18n_scope = 'simple_form'\n\n  mattr_accessor :input_field_error_class\n  @@input_field_error_class = nil\n\n  mattr_accessor :input_field_valid_class\n  @@input_field_valid_class = nil\n\n  # Retrieves a given wrapper\n  def self.wrapper(name)\n    @@wrappers[name.to_s] or raise WrapperNotFound, \"Couldn't find wrapper with name #{name}\"\n  end\n\n  # Raised when fails to find a given wrapper name\n  class WrapperNotFound < StandardError\n  end\n\n  # Define a new wrapper using SimpleForm::Wrappers::Builder\n  # and store it in the given name.\n  def self.wrappers(*args, &block)\n    if block_given?\n      options                 = args.extract_options!\n      name                    = args.first || :default\n      @@wrappers[name.to_s]   = build(options, &block)\n    else\n      @@wrappers\n    end\n  end\n","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/heartcombo/simple_form/blob/18f38aad0bdeca2ba1815043b94d96fdbbe6a325/lib/simple_form.rb#L204-L240","documentation":"SimpleForm.wrapper(name) looks up a named wrapper registered via SimpleForm.wrappers(:name) { |b| ... } in a registry hash keyed by the stringified name (lib/simple_form.rb:209,221-223). When the key is absent it raises SimpleForm::WrapperNotFound. The lookup happens at render time whenever a form or input references a wrapper by name (the wrapper: and wrapper_mappings: options), so the error surfaces while rendering a view whose wrapper was never defined.","triggerScenarios":"Calling simple_form_for @user, wrapper: :horizontal when 'horizontal' is not a key in SimpleForm.wrappers; passing f.input :name, wrapper: :compact or wrapper_mappings: { boolean: :vertical_boolean } for a wrapper name never registered in config/initializers/simple_form.rb; referencing a wrapper defined in an initializer that failed to load.","commonSituations":"Upgrading simple_form and replacing the old initializer (which held custom wrapper definitions) with a freshly generated one; copying views from another app that uses wrappers your config never defined; a per-form wrapper: option left behind after the wrapper was renamed or removed from the initializer; typos in the wrapper name.","solutions":["Define the missing wrapper in config/initializers/simple_form.rb: SimpleForm.setup { |config| config.wrappers :horizontal do |b| ... end }","Fix the name in the wrapper: / wrapper_mappings: option so it matches an existing key (names are matched as strings, symbol vs string does not matter, only spelling does)","If the custom wrapper is not needed, remove the wrapper: option so the form falls back to SimpleForm.default_wrapper (default :default)","Verify what is registered at boot with Rails.logger.info SimpleForm.wrappers.keys.inspect and compare against the names your views use"],"exampleFix":"# before (app/views/users/_form.html.erb)\n<%= simple_form_for @user, wrapper: :horizontal_form do |f| %>\n  <%= f.input :name %>  <!-- WrapperNotFound: Couldn't find wrapper with name horizontal_form -->\n<% end %>\n\n# after (config/initializers/simple_form.rb)\nSimpleForm.setup do |config|\n  config.wrappers :horizontal_form, tag: :div, class: :form-row do |b|\n    b.use :html5\n    b.use :label_input\n    b.use :error, wrap_with: { tag: :span, class: :error }\n  end\n  config.default_wrapper = :horizontal_form\nend","handlingStrategy":"validation","validationCode":"# before rendering a form that uses a named wrapper\nwrapper_name = :horizontal\nunless SimpleForm.wrappers.key?(wrapper_name.to_s)\n  raise ArgumentError, \"wrapper :#{wrapper_name} is not defined. Defined: #{SimpleForm.wrappers.keys.sort.join(', ')}\"\nend\nsimple_form_for @user, wrapper: wrapper_name do |f|\n  # ...\nend","typeGuard":"def wrapper_defined?(name)\n  SimpleForm.wrappers.key?(name.to_s)\nend\n\nwrapper_defined?(:horizontal) # => true/false; registry keys are strings","tryCatchPattern":"begin\n  SimpleForm.wrapper(wrapper_name)   # pre-resolve before render\nrescue SimpleForm::WrapperNotFound => e\n  Rails.logger.warn(\"#{e.message}; falling back to #{SimpleForm.default_wrapper}\")\n  wrapper_name = SimpleForm.default_wrapper\nend","preventionTips":["Define every wrapper referenced by views in config/initializers/simple_form.rb before boot","Add a boot-time check comparing wrapper names used in wrapper: options against SimpleForm.wrappers.keys","After upgrading or regenerating the initializer, re-add your custom wrappers before deploying views that use them","Write one view spec per custom wrapper so a missing definition fails CI instead of production"],"tags":["simple-form","wrapper","configuration","wrapper-not-found"],"backgroundTag":"wrapper-not-found","analyzedSha":"18f38aad0bdeca2ba1815043b94d96fdbbe6a325","analyzedAt":"2026-08-21T18:23:08.988Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}