Comments (10)
Sorry for the delay. Default values are removed from props for child modules. So basically when a value is empty that means your module code should treat it as if it is the default value. That being said, it is possible to force a setting's default value to be passed to the child by including 'default_on_child' => true,
in the setting definition. I hope that helps!
from create-divi-extension.
Could you provide the PHP file for the module and let me know which setting it is?
from create-divi-extension.
I tested it again and it appears to only happen inside child modules. I created a test to show the issue.
from create-divi-extension.
I am also having this issue. Any default item props are not passed in until the child settings are opened and another value is changed.
from create-divi-extension.
@BoDonkey, these props values are undefined until the component is updated.
The update can be caused by changes to props or states, for example, when the user changes the value of a field.
The question is: How can we cause an update at first so the props with default values work? (the method forceUpdate() is not recommended). And the most important one: Why aren't they set at first?
I would do that (cause an update) instead of manually store the value while the component is updated.
PS. @xxtesaxx, using the defaultProps of the component? from React? Can you give some details please?
from create-divi-extension.
If its not dynamically generated content, you could simply use the same defaults as in php. Otherwise you could probably make an ajax call to get the default value for a dynamically generated value. Accessing child values in the parent can be done via this.props.content[n].props.attrs I believe. Simply console.log(this.props) in the parents render() and check it out on the console. You'll see the parent has a content array which has one entry for each child.
from create-divi-extension.
Thank you @xxtesaxx, how can I use the same default as in php? I mean, we can access the fields values in React via props, so the field prop that have a default value (or just have a value) should be automatically added and they are not. This is the issue, these values are only passed either when they are changed or a prop that affects the prop with the default value is changed and the component is updated.
We are always discussing on defaults values set on the module fields that for some reason are not passed to the component, I'm going to check there is other parameters in the field (option_category, etc) that prevent the value to be passed, or just maybe is how it works in the visual builder. It has no sense that they are passed after a re-render though.
from create-divi-extension.
Well maybe its a bug after all :)
from create-divi-extension.
I have the exact same issue
from create-divi-extension.
Hi
i created parent child module. i set fields in child module and added default values. but when i add module in jsx default values are undefined. Please guide how i can fetch default values of child module in jsx.
2nd how i can add default nth child items when module insert
from create-divi-extension.
Related Issues (20)
- Custom fields styles no loading on Editor HOT 3
- Support for the experimental syntax 'dynamicImport' isn't currently enabled
- node-sass HOT 1
- Problem DIVI causing HTTP 500 on WooCommerce API
- Trying to get the version of the divi builder via PHP.
- How to link the field in the theme builder with the field from my custom post type
- Make upload field return image ID instead of URL
- Custom Taxonomies for Shop module
- Not able to create Divi Extensions HOT 10
- Multi-site issues with updating Divi extensions
- How to add a javascript onclick event to an element in a custom module HOT 1
- add_rewrite_rule breaks Theme/Visual Builder
- Access to @Divi/components or similar repository/package HOT 6
- displaying custom detail page while using divi templates
- DIVI Builder not workding | [React-imported-component] TypeError: n(...) is not a function
- Disable Divi Premade Layout
- et_pb_contact_form_submit not fired when JavaScript is enabled HOT 1
- How to get page specific content in rest api
- et-cache directory overpopulating
- Programmatically add divi module via php script
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 create-divi-extension.