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

Support for maxlength on string inputs inferred from validation #285

Merged
merged 3 commits into from Jul 21, 2011
Merged

Support for maxlength on string inputs inferred from validation #285

merged 3 commits into from Jul 21, 2011

Conversation

srbartlett
Copy link
Contributor

Added support for maxlength attribute to string input fields that declare validates_length_of.

Precedence is given to a field that declares a validates_length_of validation over the database column metadata limit.

The driver for this was having to repeat maxlength in both the model and the form which caught me out a few times!

Feedback welcome.

@@ -8,11 +8,12 @@ module SimpleForm

def input
input_html_options[:size] ||= [limit, SimpleForm.default_input_size].compact.min
preferred_max_length = maximum_length_from_validation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you can avoid this line changing the next to:

input_html_options[:maxlength] ||= maximum_length_from_validation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are correct. I'll make this change.

@rafaelfranca
Copy link
Collaborator

Hi mate,

thank you for the pull request. I made some comments on the code.
Good work! And thank you again to help us with this gem.

❤️

@srbartlett
Copy link
Contributor Author

No problem. Thanks for your feedback and prompt response!

Let me know if you have any other suggestions.

cheers.

@srbartlett srbartlett closed this Jul 21, 2011
@rafaelfranca rafaelfranca reopened this Jul 21, 2011
rafaelfranca added a commit that referenced this pull request Jul 21, 2011
Support for maxlength on string inputs inferred from validation
@rafaelfranca rafaelfranca merged commit bf01de6 into heartcombo:master Jul 21, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants