Comments (7)
👍 I would also love if these two plugins could work together :)
from aor-dependent-input.
Guys! the same problem! Do anyone solve it?
from aor-dependent-input.
@stephanemombuleau sure here is my version of the component with these modifications https://gist.github.com/jamesjwarren/b0facf05e8a0ce5e5daa987164e571b0
from aor-dependent-input.
Please provide us a small repository reproducing the problem
from aor-dependent-input.
This is because https://github.com/MhdSyrwan/aor-embedded-array only prefixes the source
property with the array element, it isn't aware of the dependsOn
property of DependentInputComponent
.
I was able to work around this issue with a wrapper component for DependentInput
that maps the source
property to dependsOn
:
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { DependentInputComponent, mapStateToProps } from 'aor-dependent-input/lib/DependentInput';
DependentInputComponent.propTypes = {
children: PropTypes.node.isRequired,
show: PropTypes.bool.isRequired,
source: PropTypes.any,
value: PropTypes.any,
resolve: PropTypes.func,
formName: PropTypes.string,
};
const mapStateToPropsOverride = (state, { resolve, source, value, formName }) => {
return mapStateToProps(state, {
// map source prop => dependsOn
dependsOn: source,
resolve, value, formName
});
};
export default connect(mapStateToPropsOverride)(DependentInputComponent);
Perhaps this component should use source
instead of dependsOn
to be consistent with the field components and thus ease compatibility?
Update: The above doesn't totally solve the issue. It fixes the show/hiding of the fields but child fields are not correctly prefixed by EmbeddedArrayInput
. I guess as they are now children of the DependantInput
component.
This issue can be worked around by creating a custom DependentInputComponent that utilises the EmbeddedArrayInputFormField
(aor-embedded-array/lib/mui/form/EmbeddedArrayInputFormField) in place of FormField
; with the addition of the prefix
property. The prefix value can be extrapolated from source
. This is not ideal but I doubt there will be a nice solution without a custom component.
from aor-dependent-input.
@jamesjwarren thanks for this! Do you have a snippet available for your 'update' point? That'd be awesome. Thanks.
from aor-dependent-input.
@jamesjwarren Great, thanks :)
from aor-dependent-input.
Related Issues (13)
- Use ReferenceInput under DependentInput has errors HOT 1
- Delayed updates on multiple DependentInput depending on SelectInput HOT 2
- New release? HOT 1
- Prevent yarn warning "... has incorrect peer dependency admin-on-rest@~x.x.x" with a more relaxed directive in package.json.
- Change boolean's value according to another boolean HOT 1
- Hidden <DependentField> affects the layout HOT 2
- Dependent input when both resources are based on the REST client and have a 'belongsTo' relationship? HOT 1
- React does not recognize the dependsOnValue HOT 5
- ReferenceInput HOT 2
- DependentInput does not work HOT 3
- DependentInput does not populate default values. HOT 9
- yarn warning "[email protected]" has incorrect peer dependency "admin-on-rest@~0.9.1".
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aor-dependent-input.