dependent() Firing non stop.

dependent() Firing non stop.

bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1

Link to test case: https://docs.ensaf.ac.ma/test/
Error messages shown: No error
Description of problem: Dependent working fine but keep going non stop on add or edit.

Thank you for the support.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,246Questions: 1Answers: 10,211 Site admin
    Answer ✓

    Hi,

    Thanks for the test case!

    You have:

    editor.dependent('user.country', 'scripts/php/dependentTest.php');
    

    But the script is returning:

    {
        "options": {
            "user.country": [
                {
                    "value": "1",
                    "label": "Morocco"
                },
                {
                    "value": "3",
                    "label": "Algeria"
                }
            ]
        }
    }
    

    So it is updating the options of user.country based on the selection of user.country. That triggers a change event each time, thus the infinite loop.

    I doubt you want to change the list of countries based on the selection of the country!

    You probably want to use dependent() on the continent field, and have that update the list of countries.

    Allan

  • bobhassansterbobhassanster Posts: 16Questions: 5Answers: 1
    edited January 14

    Thank you Allan for your response yes exactly but i don’t know why in my head was thinking country is depending on continent so i put country :sweat_smile: but in the php script i already was filtering on the continent.

Sign In or Register to comment.