ulion / jsonform

Build forms from JSON Schema. Easily template-able. Compatible with Twitter Bootstrap out of the box.
http://ulion.github.io/jsonform/playground/
MIT License
49 stars 27 forks source link

How to set value for type "Question" in edit mode #36

Open ihatecodinglikeking opened 7 years ago

ihatecodinglikeking commented 7 years ago

Hi, I have a type question, but i dont know how to set values in edit mode, i need to have default select depends upon option


"yes" : {
                "type": "object",
                "properties": {
                    "yes-date": {
                        "type": "string",
                    },
                    "yes-person" : {
                        "type": "string",
                    },
                },
            },
            "no-notify" : {
                "type": "object",
                "properties": {
                    "no-notify-date" : {
                        "type": "string",
                    }
                },
            },`

Form 
`{
                    "type": "questions",
                    "key": "follow-up-appointment",
                    "title": "Let's check your mood",
                    "htmlClass": "col-sm-12",
                    "items": [
                        {
                            "type": "question",
                            "title": "Are you happy?",
                            "activeClass": "btn-success",
                            "optionsType": "radiobuttons",
                            "options": [
                                {
                                    "title": "Yes",
                                    "value": "yes",
                                    "next": "q2",
                                },
                                {
                                    "title": "No",
                                    "value": "no",
                                    "next": "q3",
                                }
                            ]
                        },
                        {
                            "qid": "q2",
                            "title": "If yes, :",
                            "key": "yes",
                        },
                        {
                            "qid": "q3",
                            "title": "If no",
                            "key": "no-notify",
                        }
                    ]
                },`

value

"yes" : {
                "yes-date" : "<?=$formData['yes']['yes-date']??''?>",
                "yes-person" : "<?=$formData['yes']['yes-person']??''?>"
            },
            "no-notify" : {
                "no-notify-date" : "<?=$formData['no-notify']['no-notify-date']??''?>",
            },