Skip to content

Conversation

@andrewhwaller
Copy link

Spotted an issue for this (#46) and figured I'd take a crack at it!

This PR adds a Requirable concern that checks a form's underlying class for a presence validator on the relevant field (presence_validated?) and merges required: true into the field's attributes if such a validation is detected. If required: false is passed in, that value will be respected. I added the concern to Checkbox, Input, Select, and Textarea, since those are the field types that can take advantage of required. I also added some specs covering the Requirable behavior for all four.

Note: I wasn't sure if a concern was the way to go here. Putting this logic directly in Field felt possibly weird, so I just went with a concern to keep things modular/contained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant