You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am trying to add a default value for new items that are added on the ArrayInput using the SimpleFormIterator.
Describe the solution you'd like
diff --git a/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.d.ts b/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.d.ts
index 5adc70a..33a6083 100644
--- a/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.d.ts+++ b/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.d.ts@@ -5,6 +5,7 @@ declare const SimpleFormIterator: FC<SimpleFormIteratorProps>;
declare type DisableRemoveFunction = (record: Record) => boolean;
export interface SimpleFormIteratorProps extends Partial<Omit<FieldArrayRenderProps<any, HTMLElement>, 'meta'>> {
addButton?: ReactElement;
+ itemDefaultValue?: any;
basePath?: string;
className?: string;
defaultValue?: any;
diff --git a/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.js b/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.js
index d0212f6..95ddd36 100644
--- a/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.js+++ b/node_modules/ra-ui-materialui/esm/form/SimpleFormIterator.js@@ -119,7 +119,7 @@ var SimpleFormIterator = function (props) {
};
var addField = function () {
ids.current.push(nextId.current++);
- fields.push(undefined);+ fields.push(props.itemDefaultValue);
};
// add field and call the onClick event of the button passed as addButton prop
var handleAddButtonClick = function (originalOnClickHandler) { return function (event) {
@@ -180,6 +180,7 @@ SimpleFormIterator.defaultProps = {
};
SimpleFormIterator.propTypes = {
defaultValue: PropTypes.any,
+ itemDefaultValue: PropTypes.any,
addButton: PropTypes.element,
removeButton: PropTypes.element,
basePath: PropTypes.string,
diff --git a/node_modules/ra-ui-materialui/lib/form/SimpleFormIterator.d.ts b/node_modules/ra-ui-materialui/lib/form/SimpleFormIterator.d.ts
index 5adc70a..33a6083 100644
--- a/node_modules/ra-ui-materialui/lib/form/SimpleFormIterator.d.ts+++ b/node_modules/ra-ui-materialui/lib/form/SimpleFormIterator.d.ts@@ -5,6 +5,7 @@ declare const SimpleFormIterator: FC<SimpleFormIteratorProps>;
declare type DisableRemoveFunction = (record: Record) => boolean;
export interface SimpleFormIteratorProps extends Partial<Omit<FieldArrayRenderProps<any, HTMLElement>, 'meta'>> {
addButton?: ReactElement;
+ itemDefaultValue?: any;
basePath?: string;
className?: string;
defaultValue?: any;
Describe alternatives you've considered
No alternatives.
Additional context
For my case it's needed for proper json schema validation, issue being that if we have undefined the error is on the array index not on the properties of the object on that index, which causes the error to not be displayed.
The text was updated successfully, but these errors were encountered:
This is not for the default value of the whole input. This is the default value of an item when it is being added with the add button. Please see in patch this part fields.push(props.itemDefaultValue);
Is your feature request related to a problem? Please describe.
I am trying to add a default value for new items that are added on the
ArrayInput
using theSimpleFormIterator
.Describe the solution you'd like
Describe alternatives you've considered
No alternatives.
Additional context
For my case it's needed for proper json schema validation, issue being that if we have undefined the error is on the array index not on the properties of the object on that index, which causes the error to not be displayed.
The text was updated successfully, but these errors were encountered: