Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypted attributes always default to textarea #1829

Open
ldlamarc opened this issue Jan 27, 2024 · 0 comments · May be fixed by #1836
Open

Encrypted attributes always default to textarea #1829

ldlamarc opened this issue Jan 27, 2024 · 0 comments · May be fixed by #1836

Comments

@ldlamarc
Copy link

Environment

  • Ruby 3
  • Rails 7
  • Simple Form 5.3.0

Current behavior

When using simple form on an Active Record with encrypted fields the encrypted fields are all mapped to textarea input ignoring their database type (text or string).

Expected behavior

Use input[type=text] if the database column is a string.

Patch locally to fix it

module SimpleFormEncryptedAttributesExtension
  private

  def find_attribute_column(attribute_name)
    if @object.respond_to?(:encrypted_attributes) && @object.encrypted_attributes && @object.encrypted_attributes.include?(attribute_name)
      return @object.column_for_attribute(attribute_name)
    end

    super
  end
end

SimpleForm::FormBuilder.prepend(SimpleFormEncryptedAttributesExtension)
@ldlamarc ldlamarc changed the title Encrypted attributes always default to input[textarea] Encrypted attributes always default to textarea Jan 27, 2024
@Michaelvilleneuve Michaelvilleneuve linked a pull request Mar 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant