Support » Plugin: Calculated fields for ACF » Updating calculations with default values

  • deterius

    (@deterius)


    Hey, People of Calc Fields for ACF!

    I have been doing a little bit of a work-around for Quiz with calculations. I want to calculate the score for the quiz automatically.

    I have 10 True/False questions, then I have 10 fields that conditionally display if the question is equal to True, and has a default value of 1. So for each True response, a read-only field is displayed with a value of 1. Then the Results field simply adds all the fields together.

    However, the Results field doesn’t add all the values and doesn’t gives me the sum UNLESS I undo the read-only attribute and physically update a number (any field), then the calculation fires. Even updating/saving the posts doesn’t fire the calculations.

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author wundermatics

    (@wundermatics)

    Hi @deterius,

    This seem to be a bug with true/false fields, or a bug with readonly fields, or a combination of the two.

    I’ve done some quick testing and I see that we have issues with true/false fields, they seem to always get the value “1” internally, regardless of actual state.

    Can I ask you again to send and export of your current field definition? It was very helpful when trouble shooting the previous issue.

    deterius

    (@deterius)

    Thanks for the quick response,

    Here it is:

    {
                    "key": "field_5e549e0e1d423",
                    "label": "Score Result",
                    "name": "Score_Result",
                    "type": "group",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "formula": "",
                    "readonly": 0,
                    "show_in_graphql": 1,
                    "layout": "block",
                    "sub_fields": [
                        {
                            "key": "field_5e549e661d425",
                            "label": "Q1",
                            "name": "Q1",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": [
                                [
                                    {
                                        "field": "field_5e15a58089296",
                                        "operator": "==",
                                        "value": "1"
                                    }
                                ]
                            ],
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": 1,
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e549e861d426",
                            "label": "Q2",
                            "name": "Q2",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": [
                                [
                                    {
                                        "field": "field_5e15a5ae89297",
                                        "operator": "==",
                                        "value": "1"
                                    }
                                ]
                            ],
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": 1,
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e549ea01d427",
                            "label": "Q3",
                            "name": "Q3",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": [
                                [
                                    {
                                        "field": "field_5e15a5c789298",
                                        "operator": "==",
                                        "value": "1"
                                    }
                                ]
                            ],
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": 1,
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e549ed81d428",
                            "label": "Q4",
                            "name": "Q4",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": [
                                [
                                    {
                                        "field": "field_5e17d6de84a9d",
                                        "operator": "==",
                                        "value": "1"
                                    }
                                ]
                            ],
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": 1,
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e549eec1d429",
                            "label": "Q5",
                            "name": "Q5",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": [
                                [
                                    {
                                        "field": "field_5e4a6b7382d88",
                                        "operator": "==",
                                        "value": "1"
                                    }
                                ]
                            ],
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": 1,
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e549f071d42a",
                            "label": "Q6",
                            "name": "Q6",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": [
                                [
                                    {
                                        "field": "field_5e4a6b8082d89",
                                        "operator": "==",
                                        "value": "1"
                                    }
                                ]
                            ],
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 0,
                            "show_in_graphql": 1,
                            "default_value": 1,
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e549f2fd4111",
                            "label": "Result",
                            "name": "result",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "Q1+Q2+Q3+Q4+Q5+Q6",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        }
                    ]
                }
            ],
    Plugin Author wundermatics

    (@wundermatics)

    Hi,

    Just to let you know, we’re getting close to nailing down the issue. There will be a fix released soon.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.