Skip to content

Commit

Permalink
Pass through extra props to the form tag [#153268151]
Browse files Browse the repository at this point in the history
Signed-off-by: Ming Xiao <mxiao@pivotal.io>
  • Loading branch information
sjolicoeur authored and apps-manager committed Nov 29, 2017
1 parent f9cd9e7 commit a9280d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions spec/pivotal-ui-react/form/form_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,4 +852,17 @@ describe('Form', () => {
expect($('.grid:eq(0) .col:eq(0) input').val()).toEqual('some-name');
});
});

describe('when passed extra props', () => {
beforeEach(() => {
ReactDOM.render(
<Form {...{className: 'some-form', id: 'some-id', name: 'some-name', method: 'some-method'}} />, root);
});

it('passes them to the form tag', () => {
expect('.some-form').toHaveAttr('id', 'some-id');
expect('.some-form').toHaveAttr('name', 'some-name');
expect('.some-form').toHaveAttr('method', 'some-method');
});
});
});
4 changes: 2 additions & 2 deletions src/react/forms/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export class Form extends React.Component {
}

render() {
const {className, children} = this.props;
const {className, children, onSubmit, resetOnSubmit, onModified, onSubmitError, afterSubmit, ...other} = this.props;
const {submitting} = this.state;
const filteredChildren = React.Children.toArray(children).filter(child => {
const childIsFormRow = child.type === FormRow || child.type.prototype instanceof FormRow;
Expand All @@ -180,7 +180,7 @@ export class Form extends React.Component {
});

return (
<form {...{className: classnames('form', className), onSubmit: this.onSubmit}}>
<form {...{className: classnames('form', className), onSubmit: this.onSubmit, ...other}}>
<fieldset {...{disabled: submitting}}>
{filteredChildren.map((formRow, key) => (
React.cloneElement(formRow, {
Expand Down

0 comments on commit a9280d6

Please sign in to comment.