Drew
Drew

Reputation: 2663

Simple Form - Custom Input Not Being Recognized

So I'm wanting to have a custom input component defined for a simple form and have the following:

# app/inputs/gds_input.rb
class GdsInput < SimpleForm::Inputs::Base
  def input(wrapper_options = nil)
    binding.pry
  end
end

And then in a form I have the following:

<%= builder.simple_fields_for :registration, registration do |reg| %>
  <fieldset>
    <%= reg.input :first_name, required: true, input_html: { maxlength: 40, class: 'gds-Input' }, as: :gds_input %>
  </fieldset>
<% end %>

However I'm getting a No input found for gds_input error at RunTime.

Any thoughts as to that for which I had not accounted?

Upvotes: 2

Views: 304

Answers (1)

MrYoshiji
MrYoshiji

Reputation: 54882

Your custom class must have a suffix Input, and to use it you must remove that suffix from the underscore version of that class name.


In your case:

# class name is GdsInput
reg.input :first_name, {...}, as: :gds

Upvotes: 2

Related Questions