You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi team 馃憢馃徎 I believe I've encountered a bit of a bug.
I have an integer column in my database. Normally Formtastic would render this as <input type="number">, but I don't want it to be rendered as type="number" because the increment/decrement buttons that the browser puts on those inputs don't make sense for this column (in my case, it's a third party ID value, and thus would never be incremented/decremented, but this would apply in many scenarios).
So I render it as: :string. This uses a regular <input type="text"> but then Formtastic puts maxlength="3" on the column.
I believe this is because it [looks at the column's limit' property](https://github.com/formtastic/formtastic/blob/master/lib/formtastic/inputs/base/validations.rb#L185-L187). This makes sense for string columns - limitrefers to the limit of the string length. But forintegercolumns, thelimit` property refers to the size in bytes.
I think the fix should be to add a guard to that column_limit method that checks if column.type == :string or something, or perhaps do it in the method that calls column_limit. But I thought I'd check first whether I've misunderstood something.
In the meantime, my workaround is to add input_html: {maxlength: nil} to my input, to override this default functionality, but of course that's not ideal.
Thanks for your time.
The text was updated successfully, but these errors were encountered:
Reporting the same issue, though we use PostgreSQL and the column is an int4 array (a list of appointment IDs). We use ActiveAdmin which uses Formtastic. By default, the array gets represented as an integer input field, so we created partials that set the input as a string
= f.input :appointment_ids, as: :string, #...redacted the rest
This wasn't an issue in the past for us until we upgraded from Rails 5.1 to 5.2 earlier this year (yeah, we're pretty far behind...). Turns out that ActiveRecord made an update because limits were not being set correctly for the PostgreSQL adapter: rails/rails@1a2fe7e
So now my int4[] went from returning a nil limit to 4.
Hi team 馃憢馃徎 I believe I've encountered a bit of a bug.
I have an integer column in my database. Normally Formtastic would render this as
<input type="number">
, but I don't want it to be rendered astype="number"
because the increment/decrement buttons that the browser puts on those inputs don't make sense for this column (in my case, it's a third party ID value, and thus would never be incremented/decremented, but this would apply in many scenarios).So I render it
as: :string
. This uses a regular<input type="text">
but then Formtastic putsmaxlength="3"
on the column.I believe this is because it [looks at the column's
limit' property](https://github.com/formtastic/formtastic/blob/master/lib/formtastic/inputs/base/validations.rb#L185-L187). This makes sense for string columns -
limitrefers to the limit of the string length. But for
integercolumns, the
limit` property refers to the size in bytes.I think the fix should be to add a guard to that
column_limit
method that checksif column.type == :string
or something, or perhaps do it in the method that callscolumn_limit
. But I thought I'd check first whether I've misunderstood something.In the meantime, my workaround is to add
input_html: {maxlength: nil}
to my input, to override this default functionality, but of course that's not ideal.Thanks for your time.
The text was updated successfully, but these errors were encountered: