Skip to content

Commit

Permalink
feat(FormField): pass required to the control (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Nov 22, 2016
1 parent 37f4468 commit 0551527
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/collections/Form/FormField.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function FormField(props) {
// ----------------------------------------
// Checkbox/Radio Control
// ----------------------------------------
const controlProps = { ...rest, children, type }
const controlProps = { ...rest, children, required, type }

// wrap HTML checkboxes/radios in the label
if (control === 'input' && (type === 'checkbox' || type === 'radio')) {
Expand Down
12 changes: 12 additions & 0 deletions test/specs/collections/Form/FormField-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ describe('FormField', () => {
})
})

describe('required', () => {
it('is passed to the control', () => {
const wrapper = shallow(<FormField control='input' required />)

wrapper.should.have.exactly(1).descendants('input')

wrapper
.find('input')
.should.have.prop('required', true)
})
})

describe('label', () => {
it('is not added as a child by default', () => {
shallow(<FormField />)
Expand Down

0 comments on commit 0551527

Please sign in to comment.