Git Product home page Git Product logo

Comments (10)

lots0logs avatar lots0logs commented on September 16, 2024 1

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.

lots0logs avatar lots0logs commented on September 16, 2024

Could you provide the PHP file for the module and let me know which setting it is?

from create-divi-extension.

xxtesaxx avatar xxtesaxx commented on September 16, 2024

I tested it again and it appears to only happen inside child modules. I created a test to show the issue.

includes.zip

screen shot 2018-04-30 at 18 21 10

from create-divi-extension.

BoDonkey avatar BoDonkey commented on September 16, 2024

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.

jcdotnet avatar jcdotnet commented on September 16, 2024

@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.

xxtesaxx avatar xxtesaxx commented on September 16, 2024

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.

jcdotnet avatar jcdotnet commented on September 16, 2024

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.

xxtesaxx avatar xxtesaxx commented on September 16, 2024

Well maybe its a bug after all :)

from create-divi-extension.

jdurnil avatar jdurnil commented on September 16, 2024

I have the exact same issue

from create-divi-extension.

umertoday avatar umertoday commented on September 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.