From 767e15d305664ccf36c3784d4b83948d64d36ae5 Mon Sep 17 00:00:00 2001 From: Francois Zaninotto Date: Tue, 25 Apr 2017 20:01:50 +0200 Subject: [PATCH] Document auto translation --- docs/Inputs.md | 20 +++++++++++++++++++- src/mui/input/SelectArrayInput.js | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/Inputs.md b/docs/Inputs.md index fd1c4653a64..7d6d028e2ab 100644 --- a/docs/Inputs.md +++ b/docs/Inputs.md @@ -754,12 +754,14 @@ const choices = [ ]; ``` -However, in some cases (e.g. inside a ``), you may not want the choice to be translated. In that case, set the `translateChoice` prop to false. +However, in some cases, you may not want the choice to be translated. In that case, set the `translateChoice` prop to false. ```js ``` +Note that `translateChoice` is set to false when `` is a child of ``. + Lastly, use the `options` attribute if you want to override any of Material UI's `` attributes: {% raw %} @@ -814,6 +816,22 @@ const choices = [ ``` +The choices are translated by default, so you can use translation identifiers as choices: + +```js +const choices = [ + { id: 'books', name: 'myroot.category.books' }, + { id: 'sport', name: 'myroot.category.sport' }, +]; +``` + +However, in some cases, you may not want the choice to be translated. In that case, set the `translateChoice` prop to false. + +```js + +``` + +Note that `translateChoice` is set to false when `` is a child of ``. Lastly, use the `options` attribute if you want to override any of the `` attributes: diff --git a/src/mui/input/SelectArrayInput.js b/src/mui/input/SelectArrayInput.js index fcb023e2e8e..6e9c40f5dac 100644 --- a/src/mui/input/SelectArrayInput.js +++ b/src/mui/input/SelectArrayInput.js @@ -93,7 +93,9 @@ export class SelectArrayInput extends Component { if (this.props.choices && this.props.choices.length > 0) { return this.getChoices().filter(choice => values.includes(choice.value)); } - return []; + return values.map(value => ({ + value, text: value, // FIXME will show ids instead of labels on first paint, with no redraw + })); }; getChoices = () => {