heartcombo / simple_form

Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup.
http://blog.plataformatec.com.br/tag/simple_form
MIT License
8.21k stars 1.31k forks source link

@builder.input_field(:license_plate, type: 'radio' .... ) output a textarea tag instead of an inpt #1814

Closed troptropcontent closed 1 year ago

troptropcontent commented 1 year ago

Environment

Current behavior

In a custom input, i wanted to generate a radio input, i used the same method in other components and it worked fine but with this attribute_name ('license_plate') the output is the following :

@builder.input_field(attribute_name, type: 'radio', class: 'visually-hidden', value: value)
=> "<textarea type=\"radio\" class=\"visually-hidden\" name=\"automated_ticket[license_plate]\" id=\"automated_ticket_license_plate\">\nXXXXX</textarea>"

When i am expecting a standard ... tag 🤔

With a different attribute name it work smoothly

If you have any idea of how to make it work, i would be glad to know :)

carlosantoniodasilva commented 1 year ago

@troptropcontent I'm guessing your license_place attribute is a text db type, which SimpleForm will default to rendering a text area field.

If you want to enforce a different field option you can pass as: :string for example and it should generate an input type=text, or any other specific :as option you might need to enforce the field you want.

You can see all the available input types in the readme: https://github.com/heartcombo/simple_form#available-input-types-and-defaults-for-each-column-type.

If that doesn't solve your issue, please let us know and we can reopen and take another look.