3lvis/Form

I want to get result as well as my original JSON.

alexliubj opened this issue · 6 comments

How should I do it?

The json in test.json file to generate controls, then I fill them.
Now as you mentioned here #530 datasource.values but this one only get all the filled field with keys and values but I want a one with those values filled in my original test.json.

Any idea to do it?

Thanks,

3lvis commented

Hi @alexliubj,

I don't follow. What do you mean with:

I want a one with those values filled in my original test.json.

Could you rephrase your question, please? Adding an example could help too.

Thanks for following up on this ❤️

For e.g., you have this one here as the datasource : https://github.com/hyperoslo/Form/blob/master/Basic-Swift/Resources/forms.json

After user fill the form, I want a method to get the whole json(as forms.json) back with "value" filled in but not a piece of result in a dictionary. In the other word, I want to convert group:section:feilds those objects back to a json object.

[
  {
    "id": "first_name",
    "title": "First name",
    "info": "Fornavn",
    "type": "name",
    "disabled": true,
    "value": "my first name",
    "size": {
      "width": 30,
      "height": 1
    },
    "validations": {
      "required": true,
      "min_length": 2
    }
  },
  {
    "id": "last_name",
    "title": "Last name",
    "type": "name",
    "info": "Obs! Husk å kjøpe melk",
    "value": "my last name",
    "size": {
      "width": 30,
      "height": 1
    },
    "validations": {
      "required": true,
      "min_length": 2
    }
  }
]
3lvis commented

I understand now! Sadly we don't have support for that. Btw, what's the reason you want this? Maybe I can provide a workaround.

Hi @3lvis

Well, the purpose is simple. Json file is generated from server, server can preview it when it is generated. If client send back the same json file with filled values, server should be able to view the result as well.

Anyways, my solution is I will iterate groups->secitons->fields to generate my JSON object.

Thanks for your help.

3lvis commented

I see, makes sense, it's awesome that you found a way to preview this on the server. Let me know if there's something tricky when doing your implementation of this, and feel free to submit a pull request. 💐