Skip to content

Commit

Permalink
Merge pull request #3671 from natrim/patch-14
Browse files Browse the repository at this point in the history
[RFR][v3][BC break] SimpleFormIterator - use resource fields label
  • Loading branch information
fzaninotto authored Sep 17, 2019
2 parents 1bcc3bf + 4104921 commit 91c9094
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
13 changes: 11 additions & 2 deletions packages/ra-ui-materialui/src/form/SimpleFormIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,17 @@ export class SimpleFormIterator extends Component {
? undefined
: index2,
label:
input.props.label ||
input.props.source,
typeof input.props
.label ===
'undefined'
? input.props.source
? `resources.${resource}.fields.${
input
.props
.source
}`
: undefined
: input.props.label,
})}
record={
(records &&
Expand Down
22 changes: 12 additions & 10 deletions packages/ra-ui-materialui/src/input/ArrayInput.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,17 @@ describe('<ArrayInput />', () => {
)}
/>
);
expect(queryAllByLabelText('id')).toHaveLength(2);
expect(queryAllByLabelText('id').map(input => input.value)).toEqual([
'123',
'456',
]);
expect(queryAllByLabelText('foo')).toHaveLength(2);
expect(queryAllByLabelText('foo').map(input => input.value)).toEqual([
'bar',
'baz',
]);
expect(queryAllByLabelText('resources.bar.fields.id')).toHaveLength(2);
expect(
queryAllByLabelText('resources.bar.fields.id').map(
input => input.value
)
).toEqual(['123', '456']);
expect(queryAllByLabelText('resources.bar.fields.foo')).toHaveLength(2);
expect(
queryAllByLabelText('resources.bar.fields.foo').map(
input => input.value
)
).toEqual(['bar', 'baz']);
});
});

0 comments on commit 91c9094

Please sign in to comment.